Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Mar 2003 14:33:06 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Marcel Moolenaar <marcel@xcllnt.net>, Garrett Wollman <wollman@lcs.mit.edu>
Cc:        Craig Rodrigues <rodrigc@attbi.com>, freebsd-current@FreeBSD.ORG
Subject:   Re: #warning must be protected by #if __GNUC__ in headers?
Message-ID:  <p05200f12ba8ff3f9780e@[128.113.24.47]>
In-Reply-To: <20030308184834.GC543@dhcp01.pn.xcllnt.net>
References:  <20030308161943.GA54921@attbi.com> <200303081728.h28HSDWM039984@khavrinen.lcs.mit.edu> <20030308184834.GC543@dhcp01.pn.xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
At 10:48 AM -0800 3/8/03, Marcel Moolenaar wrote:
>On Sat, Mar 08, 2003 at 12:28:13PM -0500, Garrett Wollman wrote:
>>
>  > `#if __GNUC__' wouldn't help matters; every preprocessor has to
>  > read and interpret every preprocessor directive (so that `#else'
>  > and `#endif' can be recognized).
>
>I don't think preprocessors should interpret directives when they
>are dead (ie part of an #if block or #else block that is not to
>be compiled).

I tried to use this once, on a cross-platform program I wrote.  I
can tell you that some compilers will choke on a #warning, even if
it is inside a #if/#endif.  And other compilers will choke on #warn,
even if *it* is in a #if/#endif.  (note: some compilers which do not
recognize #warning will support #warn for the same thing).

By adding that #warning, you are going to have a compile-time error
on some compilers, whether or not you want it.  Hiding it inside of
an #if/#endif will help for some compilers, but not on all of them.

-- 
Garance Alistair Drosehn            =   gad@gilead.netel.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu

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?p05200f12ba8ff3f9780e>