How to #define variable in C -
i have file called config.h following...
#define gl_doom
then have following in file m_misc.c...
#include "config.h" ... #if ((defined gl_doom) && (defined _msc_ver)) logd("using glboom-plus.cfg"); #define boom_cfg "glboom-plus.cfg" #else logd("using prboom-plus.cfg"); #define boom_cfg "prboom-plus.cfg" #endif
but says...
05-02 14:40:24.789: d/doom(2966): using prboom-plus.cfg
what deal here? new c missing?
let's take following code:
#define gl_doom #define _msc_ver #if ((defined gl_doom) && (defined _msc_ver)) logd("using glboom-plus.cfg"); #else logd("using prboom-plus.cfg"); #endif
i can compile code g++ -e
output result of preprocessor. let's @ output.
# 1 "blah.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "blah.c" logd("using glboom-plus.cfg");
so, me, implies don't have both gl_doom
, _msc_ver
defined.
you might verify test looks like:
#include "config.h" #ifndef gl_doom #error gl_doom not defined #endif #ifndef _msc_ver #error _msc_ver not defined #endif
it's worth noting something. _msc_ver
preprocessor symbol defined strictly microsoft visual studio. if you're not compiling software, expectation would not defined.
Comments
Post a Comment