I have a requirement to build an automated system to parse a C++ .h file with a lot of #define
statements in it and do something with the value that each #def
Can you use g++
or gcc
with the -E option, and work with that output?
-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files which don't require preprocessing are ignored.
With this, I imagine:
#define
keys from the sourceOne of these two commands:
gcc -E myFile.c
g++ -E myFile.cpp
https://gcc.gnu.org/onlinedocs/gcc-2.95.2/gcc_2.html https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html