Thursday, December 21, 2006

C Macro Tricks

If you know C programming, you should know C macro as well. Macro is very powerful. However, it also makes the code difficult to read, especially macro with multi-level expansion. In complication of source code, the macro expansion is handled by "C Preprocessor". To do trouble-shooting on macro expansion, we can use the "-E" option in gcc. The "-E" option tells the compiler to stop after "C Preporcessor". With "-E" option the output file of gcc will be a text file containing the source code with all macro expanded and #include files merged.

No comments: