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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

howto: Preprocessor Directives inside #define statements

Status
Not open for further replies.

AMosmann

Programmer
May 27, 2003
82
DE
Hi, I want to write a #define-macro that, depending on other defines, TRACEs some text into a file.
No way to find an explaining, how to use precompiler directives inside a #define- Macro.

A define like

#define ZTRACE(LEVEL,STRING) #ifndef TRACELEVEL #define TRACELEVEL 1 #endif

gives an error C2162, and I do not know, what to do...
I tried a lot...

Many thanks
[ponder]



Greetings Andreas
 
Flip your design around

#ifndef TRACELEVEL
#define TRACELEVEL 1
#endif

#define ZTRACE(LEVEL,STRING) ... rest of macro

-pete
 
sorry, it is not the same.

>#ifndef TRACELEVEL
>#define TRACELEVEL 1
>#endif

>#define ZTRACE(LEVEL,STRING) ... rest of macro

...

#undef TRACELEVEL
ZTRACE(1,"Any String"); // will cause an error, if I use TRACELEVEL in the MACRO

but thx anyway, pete [thumbsup]


Greetings Andreas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top