Free Software programmer
This blog existed before my current employment, and obviously reflects my own opinions and not theirs.
This work is licensed under a Creative Commons Attribution 2.1 Australia License.
Wed, 18 Oct 2006
The kernel used to have a problem that people would use the CONFIG_ pre-processor variables but not include the "linux/config.h" header, resulting in strange bugs as some files were built with the option, and some without.
#ifdef CONFIG_MODULES some expression #endif
This was solved in the kernel by putting "-include linux/config.h" on the gcc command line to always ensure its inclusion. But an alternative is to change to using #if instead:
#if CONFIG_MODULES some expression #endif
This does the same thing (undefined symbols in CPP are equivalent to 0), but now you can define every switch to 0 or 1 and use -Wundef: GCC will warn if the option is undefined.
[/tech] permanent link