3 ms·
Linux kernel has a lot of these compile time optional struct members. I think they avoid this issue by using a config header file that contains the defines, so
by megous 6y ago
Linux kernel has a lot of these compile time optional struct members.
I think they avoid this issue by using a config header file that contains the defines, so the compilation unit either compiles with the config header, or if it's not included and config macro is used, compilation fails altogether.
It's still possible to include different config header than you're expecting, though. But that's easier to defend against. (you can just include a config header directly via cmd line without using #include <...> in each compilation unit)
It's also better to use #if MACRO = 1 instead of #ifdef MACRO, because the first one will fail if MACRO is not defined.