Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does clang -dumpversion report 4.2.1

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?

like image 996
arved Avatar asked Oct 15 '12 10:10

arved


People also ask

What is current Clang version?

Clang 14, the latest major version of Clang as of March 2022, has full support for all published C++ standards up to C++17, implements most features of C++20, and has initial support for the upcoming C++23 standard.

Does Clang support C ++ 20?

C++20 implementation statusClang has support for some of the features of the ISO C++ 2020 standard. You can use Clang in C++20 mode with the -std=c++20 option (use -std=c++2a in Clang 9 and earlier).

Why does Apple use Clang?

The Clang Compiler is an open-source compiler for the C family of programming languages, aiming to be the best in class implementation of these languages. Clang builds on the LLVM optimizer and code generator, allowing it to provide high-quality optimization and code generation support for many targets.

What does Clang error mean?

First you get the error because the compiler can not find the definition of the power function that you are using. Even if you write int power(int m, int n); There is an error because you are not defining the function.


1 Answers

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.

like image 73
thakis Avatar answered Nov 15 '22 11:11

thakis