Is it only ANSI C that allow #if to compare symbols?
Leif Andrew Rump
andrew at resam.dk
Sat Jan 19 04:09:21 AEST 1991
Hello netters - please help me with this one - this will be the last one -
and if you believe that then I have an Eiffeltower to sell you!!! :-)
I tried this construction on our Sun C compiler (please no flames!):
#define FOLDER fk
...
#ifdef FOLDER
part 1
#endif
...
#if FOLDER == fk
part 2
#endif
It worked OK for part 1 i.e. if FOLDER is defined (never mind it's
value) then part 1 if compiled but part 2 get compiled under any
circumstances _even_ if you only define one of two symbols and write:
#ifdef FOLDER == CASE
part 2
#endif
So this rules out that the presence is equal 1 and absence equal 0!
The manual states "#if constant-expression ... All binary non-assign=
ment C operators, including '&&', '||' and ',', are legal ... The '?:'
operator, and the unary '-', '!', and '~' operators, are also ..."
Is there any other way I may check a symbols value?
Any suggestions?
Leif Andrew
Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark
UUCP: andrew at ambra.dk, phone: +45 39 27 11 77 /
Currently at Scandinavian Airline Systems =======/
UUCP: andrew at resam.dk, phone: +45 32 32 51 54 \
SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark
> > Read oe as: o <backspace> / (slash) and OE as O <backspace> / (slash) < <
More information about the Comp.lang.c
mailing list