Rate This Document
Findability
Accuracy
Completeness
Readability

Clang Macro Problem

Problem

The program code logic uses the __GNUC__ macro as the basis for decision making. However, the macro content in GCC is different from that defined in Clang. You can run the following command to check the value defined by the macro in Clang:

1
clang -x c /dev/null -dM -E >clang.log;cat clang.log|grep '__GNUC__'

Solution

If an error is reported due to inconsistent macro content, add `-D__GNUC__=x` to compiler options for adaption and modification.