N
Noob
Hello,
I suppose this topic is tool-specific, but it seems to me
many tools have adopted the same behavior.
I had always been under the (mistaken) impression that defining
a macro on the command line (with -D) was equivalent to defining
it in my source file (with #define).
In other words, that
cc -DFOO bar.c
was equivalent to having
#define FOO
as the first line of bar.c
but it appears I was wrong...
-DFOO seems, in fact, to be equivalent to
#define FOO 1
(and also to -DFOO=1 but I digress)
So I can't just write
#if FOO1 && FOO2 && !FOO3 && (FOO4 || !FOO5)
if FOOi could be either defined on the command line
or as a simple #define in the source file, right?
If I want to use the syntax without defined(),
I have to actually define the macro to 1.
I think it is guaranteed that an undefined macro
will have value 0 in a #if expression, right?
Regards.
I suppose this topic is tool-specific, but it seems to me
many tools have adopted the same behavior.
I had always been under the (mistaken) impression that defining
a macro on the command line (with -D) was equivalent to defining
it in my source file (with #define).
In other words, that
cc -DFOO bar.c
was equivalent to having
#define FOO
as the first line of bar.c
but it appears I was wrong...
-DFOO seems, in fact, to be equivalent to
#define FOO 1
(and also to -DFOO=1 but I digress)
So I can't just write
#if FOO1 && FOO2 && !FOO3 && (FOO4 || !FOO5)
if FOOi could be either defined on the command line
or as a simple #define in the source file, right?
If I want to use the syntax without defined(),
I have to actually define the macro to 1.
I think it is guaranteed that an undefined macro
will have value 0 in a #if expression, right?
Regards.