Description Usage Arguments Details Value Author(s) References See Also
The getCppDefines
function attempts to get the definitions of the
pre-processor definitions from one or more header/source files
by using GCC's ability to emit the table of macro definitions.
It compares the collection of defined symbols to that without
the source file (but with specified system header files) so as
to find the ones that are actually defined within the user-level
source files and not the system definitions.
These can then be processed further to organize them into different
categories using, e.g.
processDefines
and filterMacros
.
1 2 | getCppDefines(fileName = character(), cppFlags = "", cpp = "g++",
flags = "-E -P -dM", sysIncludes = c("stdlib.h", "stdio.h"))
|
fileName |
the name of the C/C++ source file which is to be passed to the pre-processor. This is the file containing the code for which we want to extract the pre-processor definitions. |
cppFlags |
any extra C/C++ pre-processor flags needed for
processing |
cpp |
the name of the C/C++ pre-processor. By default, we use
the GCC C++ compiler and instruct it to only run the pre-processor
phase of the compilation via the |
flags |
additional flags or command line-arguments to be passed
to the pre-processor command (i.e. |
sysIncludes |
a character vector which gives the names of the
system-level include files which are to be treated as the baseline.
These are used by first computing all the macro definition symbols
that occur in these files (and the compiler/pre-processor itself)
and removing these from the symbols that are found when
we apply the pre-processor to the the user-specified source file, i.e.,
|
This uses the GCC suite's ability to dump the table of pre-processor symbols via command line arguments.
A character vector giving the set of macro definitions
as lines of the form "#define SYM definition"
.
Macros that have multi-line definitions will have multiple
entries in this vector with the subsequent lines of the definition
being successive elements in the result.
These are manipulated and pulled into single
definitions using processDefines
.
Duncan Temple Lang
The GCC pre-processor
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.