I have three closely related applications that are build from the same source code - let's say APP_A, APP_B, and APP_C. APP_C is a superset of APP_B which in turn is a superset of APP_A.
So far I've been using a preprocessor define to specify the application being built, which has worked like this.
// File: app_defines.h
#define APP_A 0
#define APP_B 1
#define APP_C 2
My IDE build options then specify (for example)
#define APPLICATION APP_B
... and in source code, I will have things like
#include "app_defines.h"
#if APPLICATION >= APP_B
// extra features for APPB and APP_C
#endif
However, I shot myself in the foot this morning and wasted far to much time by simply omitting the line to #include "app_defines.h" from one file. Everything compiled fine, but the application crashed with AVs at startup.
I'd like to know what a better way of handling this would be. Previously, This would normally one of the few times when I'd consider #define could be used (in C++, anyway), but I still goofed up badly and the compiler didn't protect me.