Search code examples
ceclipsemacroseclipse-cdtc-preprocessor

What is a Preprocessor Macros File in Eclipse CDT?


In Eclipse CDT there is an entry type "Preprocessor Macros File" under Project Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc. -> Entries -> CDT User Setting Entries -> Add.

What is the purpose and format of such a file, in particular as opposed to a normal include file?

The Eclipse version is Luna Release (4.4.0) with CDT 8.4.0.


Solution

  • It allows you to tell Eclipse CDT to parse a C header file for defined preprocessor macros. For example to use GCC's C99 default preprocessor macros, without having to add them all individually, first generate the header file:

    gcc -std=c99 -dM -E - < /dev/null > gccmacros_c.h
    

    And then have Eclipse use that header file that was generated as a Preprocessor Macros File. I find this useful as a step when setting up Eclipse CDT's indexer to work properly with remote and cross compile C/C++ projects.

    Edit: For more info see https://wiki.eclipse.org/HowTo_use_the_CDT_to_navigate_Linux_kernel_source and https://askubuntu.com/a/188127