How to distinguish MYDEF and MYDEF() with #ifdef

Frank Winklmeier frank.winklmeier@cern.ch
Tue Jul 24 12:53:00 GMT 2007


Hi,

I have two different versions of an include file that in one version 
defines

#define MYDEF { ... }

and in the other version it defines the same but with "()":

#define MYDEF() { ... }

My code needs to work with both, but for #ifdef both seem to be the 
same. However, trying to execute MYFUNC() if only MYFUNC is defined 
results in a compile time error. My idea was to use

#ifdef MYDEF
   MYDEF;
#elif defined MYDEF()
   MYDEF();
#endif

but the first #ifdef evaluates to true in both cases. Any idea how to do 
this?

Thanks,
Frank



More information about the Gcc-help mailing list