Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Nov 2001 10:50:18 +0100 (CET)
From:      Cyrille Lefevre <clefevre@citeweb.net>
To:        Warner Losh <imp@harmony.village.org>
Cc:        Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>, freebsd-current@FreeBSD.ORG
Subject:   Re: malloc.h
Message-ID:  <200111080950.fA89oIk21059@gits.dyndns.org>
In-Reply-To: <200111080839.fA88dv740802@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Warner Losh wrote:
> In message <20011108075021.P43204@uriah.heep.sax.de> Joerg Wunsch writes:
> : > #if (__STDC__-0) == 0
> : 
> : What is the difference to my version (except that it would fail for
> : __STDC__ being greater than 1)?  I don't know how pre-ANSI cpps did
> : behave, but at least a standard-conformant cpp must replace any
> : identifier in an #if statement that remains after macro expansion by
> : 0L.

the difference is that if __STDC__ isn't defined, #if (-0)==0 continue
to work.

> It isn't different.  Some people like to
> 	#define TRUE (1 == 1)
> too, which is bogus, imho.  They like to trot out the fact that some
> whacked out compiler from the 1980's or earlier defined TRUE to be 255
> or something like that. :-).
> 
> I wouldn't worry about it
> 
> #if __STDC__
> 
> is exactly right.

I still remember me some compiler (cpp) which complain on such
statement if the symbol is undefined and __STDC__ isn't always
defined under some compiler (don't remember which).

IMHO, the correct statement is :

#ifdef __STDC__
#define GOODCPP
#if __STDC__
#define ANSI
#else
#undef ANSI
#endif
#else
#define WRONGCPP # cpp can't handle #x or x##x in macro
#under ANSI
#endif

also, as I remember me, Solaris or HP uses the construction I post
in they headers.

> Older, pre ANSI cpp would treat this correctly, unless they were very
> very very old and didn't have the #if directive, but only the #ifdef
> directive.  That's so old, I've never seen one, but rumors about their
> existitance filled comp.lang.c in 1985-1989 when I still had time for
> netnews.

I'm sure I encountered this problem until 1995 at least.

Cyrille.
-- 
Cyrille Lefevre                 mailto:clefevre@citeweb.net

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111080950.fA89oIk21059>