Date: Mon, 27 Aug 2001 18:42:28 -0700 From: "Mark D. Anderson" <mda@discerning.com> To: <freebsd-hackers@freebsd.org> Cc: "Charles Randall " <crandall@matchlogic.com> Subject: Re: Portability of #warning in /usr/include Message-ID: <08e601c12f62$c48b79a0$6c456420@mdaxke>
next in thread | raw e-mail | index | archive | help
> This may not work. >... > Some of those compilers > would NOT let you '#ifdef' out the version that it did not recognize > (perhaps thinking that '#warn' or '#warning' might be some gross typo > for '#else' or '#endif', I guess...). this is true; some compilers seem to require that #ifdef'd out code be syntactically correct. while #warning is not available in ISO C, #error is. it was deliberate to omit #warning; there is nothing in the standard to require #error to be fatal. one could easily argue that #warning would have been useful, even if the distinction between #warning and #error is hazy. i don't think pragmas offer a solution, in either the "#pragma warning" or "_Pragma" forms. i do not think gcc supports a "warning" pragma however (as in #pragma GCC warning foobar or _Pragma("GCC warning foobar")), nor is their such a thing in the STDC pragma namespace. one sure way to make things work is to move compiler-specific things to compiler-specific headers, which would probably be a good idea anyhow. something like including a "compiler_specific.h" which would in turn contain stuff like: #ifdef __GNUC__ #include "gnu_cruft.h" #elif __TenDRA__ /* don't know if this is what it is called */ #include "tendra_cruft.h" #else #error what compiler is this? #endif -mda To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?08e601c12f62$c48b79a0$6c456420>