C
Charlie Zender
Hi,
I want to have a CPP macro that tests the value of a token and
returns the string "No" if the token is undefined (or 0) and
returns "Yes" if the token is defined (non-zero).
Then I can have C code that self-diagnoses its configuration with,
e.g.,
#define TKN2YESNO(x) ((x)==0 ? ("No")"Yes"))
(void)fprintf(stderr,"The token FOO is defined: %s",TKN2YESNO(FOO));
(void)fprintf(stderr,"The token BAR is defined: %s",TKN2YESNO(BAR));
However, my definition of TKN2YESNO() does not work.
The GCC compiler on Linux flags an when I invoke TKN2YESNO() as above:
nco_scm.c:195: error: `FOO' undeclared (first use in this function)
Any help in understanding the cause of this error and how to correct
it to achieve the desired functionality would be appreciated!
Thanks,
Charlie
I want to have a CPP macro that tests the value of a token and
returns the string "No" if the token is undefined (or 0) and
returns "Yes" if the token is defined (non-zero).
Then I can have C code that self-diagnoses its configuration with,
e.g.,
#define TKN2YESNO(x) ((x)==0 ? ("No")"Yes"))
(void)fprintf(stderr,"The token FOO is defined: %s",TKN2YESNO(FOO));
(void)fprintf(stderr,"The token BAR is defined: %s",TKN2YESNO(BAR));
However, my definition of TKN2YESNO() does not work.
The GCC compiler on Linux flags an when I invoke TKN2YESNO() as above:
nco_scm.c:195: error: `FOO' undeclared (first use in this function)
Any help in understanding the cause of this error and how to correct
it to achieve the desired functionality would be appreciated!
Thanks,
Charlie