4 ms·
Since some people are posting macros (including some intentionally malicious ones), it is handy to know the -E compiler flag for debugging purposes. This will r
by sdevlin 15y ago
Since some people are posting macros (including some intentionally malicious ones), it is handy to know the -E compiler flag for debugging purposes. This will run only the preprocessor on the given files and print the result to stdout. (N.b. -E works at least on gcc and clang; the flag may be different elsewhere.)
Not really a C language trick, but useful nonetheless.
- mansr 15y agoThe -E flag is specified by POSIX. Non-POSIX compilers sometimes support it, sometimes not.
- silentbicycle 15y agoYou can also call 'cpp' on the file. When doing heavy macrology (e.g. https://github.com/silentbicycle/kona/blob/master/scalar.h https://github.com/silentbicycle/kona/blob/master/scalar.h) I like to work in a file which is just #include "the_macro.h" THE_MACRO(example, args); and call cpp macrotest.h | fmt -w72 (using fmt since multi-line macros will end up on one line otherwise).