Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I embed ##ifdef in a macro?

Status
Not open for further replies.

Vovin

Programmer
Aug 24, 2003
63
GB
Hi,

I have a macro of the form:

#define MACRONAME (expr) OTHER_MACRO_TO_CALL (expr)

however I only want the macro OTHER_MACRO_TO_CALL to be called if a certain token is already defined. For example something like this:

#define MACRONAME (expr) \
#ifdef MY_TOKEN \
OTHER_MACRO_TO_CALL (expr) \
#endif

This however doesn't work. Is there any way of doing this? Any help would be much appreciated. Thanks.
 
How about inverting the condition
Code:
#ifdef MY_TOKEN
#define MACRONAME(expr) OTHER_MACRO_TO_CALL(expr)
#else
#define MACRONAME(expr)
#endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top