Is it possible to have a header file compile differently in two different source files by using defines in the source files?
For example, if i have a single header included in two source files as in:
header.h:
#if FOO
#define BAR(x) f(x)
#else
#define BAR(x) g(x)
#endif
source1.cpp:
#define FOO 1
#include "header.h"
void a(int x) {
BAR(x); // f(x)?
}
source2.cpp
#include "header.h"
void b(int x) {
BAR(x); // g(x)?
}
Should this not compile so that function a performs f and function b performs g?
I'm trying to do this in XCode and Objective-C++. Both a and b perform g as if source1.cpp didn't define FOO.