10

I was trying to use -dumpversion to determine if the compiler is usable. My project compiles with clang and newer gccs, but not with the old gcc 4.2.1.

So why does clang pretend to be an old gcc?

Extra questions, is it possible to change this value at runtime?

Or does anyone have a nice autoconf macro to determine the compiler version with both clang and gcc?

arved
  • 4,401
  • 4
  • 30
  • 53

1 Answers1

7

Clang was originally written to be compatible with gcc 4.2.1. There has been some discussion about updating that number earlier this year, but there were issues.

For autoconf checking, clang suggests to use its __has_feature extension. Clang's document has a list of things you can check with __has_feature too.

thakis
  • 5,405
  • 1
  • 33
  • 33
  • 1
    Is the __has_feature also supported by gcc? – arved Nov 07 '12 at 10:23
  • __has_feature would be great if they also maintained a __has_bug() list of attributes as well. Most of the time when I have to alter my makefiles it's because I'm having to do workarounds for bugs specific to certain compilers. – jstine Apr 04 '14 at 21:00
  • 1
    Updating the spurious version number is the wrong direction. Clang should abandon the practice altogether. Its a first class compiler, and it does not need to pretend to be other compilers. Also see [How to tell Clang to stop pretending to be other compilers?](http://stackoverflow.com/q/38499462) – jww Aug 24 '16 at 05:56