The Preprocessor Result of Clang Is Greatly Different from That of GCC
Error Information
- Formats are incorrect (syntax error, unexpected IDENT).
- Header files cannot be found.
Problem
The preprocessor implementation of Clang is greatly different from that of GCC. Examples are as follows:
- Clang retains the space characters at the beginning of each line.
- Clang retains the absolute path of the imported header file.
- Other differences are not listed one by one.
Some programs use the preprocessor to process source code files. However, the processor of Clang is different from that of GCC, which may cause problems.
Solution
Modify the source code so that it can be correctly processed by the preprocessor of Clang. Examples are as follows:
- Delete the space characters at the beginning of code lines.
- Ensure that files in the include directory can be found.
Parent topic: Other Compatibility Problems