Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recognizing clang, gcc, and tcc by implementation-defined macros

Tags:

c

gcc

macros

clang

tcc

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)?

like image 855
PSkocik Avatar asked Sep 12 '16 08:09

PSkocik


1 Answers

Use __TINYC__ to detect tcc1.

Detection of gcc and clang is explained in this StackOverflow question: Detect gcc as opposed to msvc / clang with macro


1 (Quoted from: http://bellard.org/tcc/tcc-doc.html#SEC9)
__TINYC__ is a predefined macro to 1 to indicate that you use TCC.

like image 137
2501 Avatar answered Nov 03 '22 02:11

2501