[lug] OT: CPP question

Sexton, George gsexton at mhsoftware.com
Fri Mar 29 13:54:34 MST 2002


I have a question about CPP, and I was hoping someone could help me.

Given:

#ifdef THIS
#define MY_FUNC(x) SomeFunction(x)
#else
#define MY_FUNC(x) SomeOtherFunction(x)
#endif

MY_FUNC(some_literal);


If THIS is defined, I would like the output to be:

SomeFunction('some_literal');

but if THIS is not defined, I would like the output to be:

SomeOtherFunction(some_literal);

I tried MY_FUNC(x) SomeFunction('x') but it gives:

SomeFunction('x');

I tried MY_FUNC(x) SomeFunction(''x'') but it gives:

SomeFunction(''some_literal'');

Does anyone have an idea on how I can create the macro so that in one form
the output is the literal single quoted, but in another it is just the
literal?


George Sexton
MH Software, Inc.
Voice: 303 438 9585
http://www.mhsoftware.com





More information about the LUG mailing list