What is a preprocessor macro file in Eclipse CDT?

Eclipse CDT has an entry type "Preprocessor Macros File" under Project Properties → C / C ++ General → Preprocessor Include Paths, Macros, etc. → Entries → CDT Customizing Entries → Add.

What is the purpose and format of such a file, specifically as opposed to a regular include file?

Eclipse version - Luna release (4.4.0) with CDT 8.4.0.


source to share

2 answers

This allows you to tell Eclipse CDT to parse the C header file for specific preprocessor macros. For example, to use the default GCC C99 preprocessor macros without adding them separately, first create a header file:

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


And then Eclipse uses this header file, which was generated as a preprocessor macro file. I find this useful as a step in setting up the Eclipse CDT indexer to work properly with remote and cross-compiled C / C ++ projects.

Edit: See https://wiki.eclipse.org/HowTo_use_the_CDT_to_navigate_Linux_kernel_source and https://askubuntu.com/a/188127 for details



Another way is to use the XML project settings and add all the required macros there. You can create a basic XML file with

Right Click on Project -> Go to properties -> C/C++ General -> Path and Symbol


and on the tab Symbol

add several pre-processor

for GNU C

or GNU C++

and export these parameters to a file using the "Export Settings" link at the bottom of the window. Then manually edit the XML file for the new macros and import using the Import Options button in the above option.

Use the saved file as a template for all other projects and import it once during project creation.



All Articles