I need to include a #define at the top of around 300 .c files. I would prefer not to change the code as it is open source code but if I have to I will just write a script to modify all the files. Is there a way using gcc to add a #define or header file include to the top of every source file during compilation? The #define is this:
#define malloc MYmalloc
You can pass
-Dmalloc=MYmallocto thegccoptions.For more information about the
-Doption:http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
Note that if you want to modify the behavior of
mallocfunction for debugging purposes, you may also be interested inglibcmallochooks:http://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html