M
Martijn
Hi,
I hope I am in the right place on preprocessor help, 'cause the GNU
preprocessor documentation is somewhat minimal on this topic.
Assume I have two #define'd constants:
#define STRING1 "string"
#define STRING2 NULL
The code I want to compile is something like this:
char *sz1 = NULL;
char *sz2 = NULL;
if ( STRING1 )
sz1 = strdup(STRING1);
if ( STRING2 )
sz2 = strdup(STRING2);
(traded style for brevity)
I tried a conditional micro at first ( #if STRING1 ), but that makes the
preprocessor choke. If I use the construct above, I get a warning for each
time I use it (about strdup requiring a non-NULL argument).
Is there a better alternative than what I am presenting here?
Thanks for your time and help,
I hope I am in the right place on preprocessor help, 'cause the GNU
preprocessor documentation is somewhat minimal on this topic.
Assume I have two #define'd constants:
#define STRING1 "string"
#define STRING2 NULL
The code I want to compile is something like this:
char *sz1 = NULL;
char *sz2 = NULL;
if ( STRING1 )
sz1 = strdup(STRING1);
if ( STRING2 )
sz2 = strdup(STRING2);
(traded style for brevity)
I tried a conditional micro at first ( #if STRING1 ), but that makes the
preprocessor choke. If I use the construct above, I get a warning for each
time I use it (about strdup requiring a non-NULL argument).
Is there a better alternative than what I am presenting here?
Thanks for your time and help,