c - how to define a macro to a macro -
i want define this:
#define is_proc_one defined(sp_proc_type_one)
or
#define is_proc_one (#define 1 1)
is there way this?
notes: have try following codes, works.
#define 1 #define 2 defined(one) int main() { #if 2 printf("test success\n"); #endif return 0; }
you can't define macro in other macro.
according c99 section (6.10.3.4 #2)
if nested replacements encounter name of macro being replaced, not replaced. these nonreplaced macro name preprocessing tokens no longer available further replacement if later (re)examined in contexts in macro name preprocessing token otherwise have been replaced.
further in ( #3)
the resulting macro-replaced preprocessing token sequence not processed preprocessing directive if resembles one
one way think can work :
#define 1 one #define is_proc_one 1
Comments
Post a Comment