osx - Porting C code with #ifdef and #ifndef (C preprocessor) -
i'm porting iphone game mac , i'm writing file common defines has following:
// first reset defines #undef target_iphone #undef target_mac // set defines #if target_os_mac #if target_os_iphone #define target_iphone #else #define target_mac #endif #endif #ifdef target_iphone #error err1 #endif #ifndef target_iphone #error err2 #endif
but when building iphone, both err1 , err2 thrown compiler.
i don't it, what's problem there?
edit: after hour of trying things no luck, had add own define xcode build options.
your code fine. on compiler (gcc mingw) #error err2
thrown. , if insert
#define target_os_mac 1 #define target_os_iphone 1
where // set defines
is, #error err1
thrown.
Comments
Post a Comment