Subject: the "warned_unix" hack in GCC's preprocessor is poorly concieved....
To: NetBSD Toolchain Technical Discussion List <tech-toolchain@NetBSD.ORG>
From: Greg A. Woods <>
List: tech-toolchain
Date: 03/30/2003 12:58:13
While I can appreciate it when the compiler (or as in this case, the
preprocessor) can tell me about features I might be using which are not
supported by the current environment, I also would really prefer if
there were some proper way to disable these warnings when either they
are inappropriate or even completely bogus.

The warning I'm particularly concerned with today is:

	file.h:999: warning: deprecated symbol "unix" is no longer predefined

In this particular case the code quite legitimately says:

	#if defined(sun) && defined(unix)

Unfortunately the way the warning is implemented it can't know at the
time it is printed that this symbol is being used in an expression where
its value or presense cannot matter (because of course the other term
can never be true either).

Now for foreign code that has to work on systems which still do define
the "unix" macro then it would be nice to be able to tell NetBSD's
compiler to just forget completely about this warning with a command-
line option like "-Wno-cpp-warn-unix".

For now I guess I can just avoid the problem with:

#if defined(__NetBSD__) && defined(__GNUC__)
# define unix		1	/* avoid bogus warning */

I.e. I think it's a lot cleaner to control the warning messages directly
rather than confusing things even more by defining the missing macro.

It would be nice if other similar (Net)BSD-specific warnings could be
controlled in a similar manner (e.g. esp. warnings about questionable
function use, such as mkstemp()).

I suppose I could provide a patch, but given this is GCC I think it
would be better if such a change came directly from one of the
"approved" GCC hackers....

								Greg A. Woods

+1 416 218-0098;            <>;           <>
Planix, Inc. <>; VE3TCP; Secrets of the Weird <>