If I want to expand a C macro, what are some good ways to do that (besides tracing it manually)?
For instance, GTK_WIDGET_SET_FLAGS
, it uses a macro that
In Visual Studio, you can generate the preprocessor resulted translation unit file. You can go project options, C/C++/Preprocessor and put "Generate Preprocessed File" or "Preprocess to a File" on Yes (or use /P or /EP compiler switch to include line numbers or not).
gcc even with -E needs the path of the header files ... like -I _path_to_your_headers...
If you've a Makefile, generally, what you could do is over-riding CC with gcc -E
Generally, cpp is only a script adding some flags to gcc for the preprocessor, like traditional...
Try running cpp on your source file
gcc -E myfile.c
Have you tried running gcc -E multiple times until there are no longer any macros?
When trapped in a sketchy IDE, try something like
#define DISPLAY_VALUE2(x) #x
#define DISPLAY_VALUE(x) DISPLAY_VALUE2(x)
#pragma message("#DEFINE F_CPU " DISPLAY_VALUE(F_CPU))
to produce
…/sketch_may21a.ino: In function 'void loop()':
…/sketch_may21a.ino:10:54: note: #pragma message: #DEFINE F_CPU 16000000L
#pragma message("#DEFINE F_CPU " DISPLAY_VALUE(F_CPU))
^
thanks to "mdematos" at http://MicroChip.com/forums/m724722.aspx