7

I use clang, gcc, and tcc, and I'd like to be able to differentiate between the three in a common header.

Judging by their macro dumps, I expect that the presence of the __clang__ macro will uniquely identify clang.

I'm unable to get a macro dump with tcc ( $compiler -x c -E -dM /dev/null doesn't work in its case ).

What is the macro(s) (if any) that will uniquely identify gcc (and possibly tcc)?

4

1 回答 1

10

使用 __TINYC__ 检测 tcc 1

这个 StackOverflow 问题解释了 gcc 和 clang 的检测:Detect gcc 而不是 msvc / clang with macro


1(引自:http ://bellard.org/tcc/tcc-doc.html#SEC9 )
__TINYC__ 是一个预定义的宏 1,表示您使用 TCC。

于 2016-09-12T09:03:50.880 回答