[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GCC predefines



On Thu, Sep 12, 2002 at 08:39:29AM +0200, Martin v. Loewis wrote:
> "Joel Baker" <lucifer@lightbearer.com> writes:
> 
> > Both are ELF systems, and both define the OS standard symbol for their
> > respective OSen. However, what I can't figure out is why the NetBSD config
> > doesn't have -Dunix - it certainly seems to support the various files that
> > I've seen that used as a trigger for (unistd.h, etc).
> 
> You can't be really certain that the NetBSD config doesn't have
> -Dunix. In gcc 3.2, these things are not controlled through the spec
> file anymore.
>
> Instead, the function builtin_define_std is invoked at runtime. If it
> is invoked as
> 
> 	builtin_define_std ("unix");
> 
> then the preprocessor will define __unix and __unix__, and, unless
> --std=c89 is specified, it will also define unix.
> 
> To find out what is defined, compile an empty C file with -v -E.

So noted; however, I went looking *because* it isn't doing -Dunix or the
equivalent, thus breaking things that one might normally expect to work
(well, I don't know the wisdom of the piece of coding basing unistd.h
off of #ifdef unix, but still... it *appears* to have the pieces of the
standard, so I wonder why it isn't being defined)

For the record, however:

root@thenet# touch foo.c
root@thenet# gcc -v -E foo.c
Reading specs from
/usr/lib/gcc-lib/i386-unknown-netbsdelf-debian/3.2.1/specs
Configured with: /tmp/Build/gcc-3.2/gcc-3.2-3.2.1ds0/src/configure -v --enable-languages=c,c++,f77,proto,objc --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --disable-__cxa_atexit --enable-objc-gc i386-unknown-netbsdelf-debian
Thread model: single
gcc version 3.2.1 20020830 (Debian prerelease)
 /usr/lib/gcc-lib/i386-unknown-netbsdelf-debian/3.2.1/cpp0 -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=1 -D__GXX_ABI_VERSION=102 -D__NetBSD__ -D__ELF__ -D__NetBSD__ -D__ELF__ -Asystem=unix -Asystem=NetBSD -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ foo.c
GNU CPP version 3.2.1 20020830 (Debian prerelease) (cpplib) (NetBSD/i386 ELF)
ignoring nonexistent directory "/usr/i386-unknown-netbsdelf-debian/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/i386-unknown-netbsdelf-debian/3.2.1/include
 /usr/include
End of search list.
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"

> > Is this just a crufty value from Days of Yore when NetBSD didn't have
> > support for the standard that symbol represents? If so, which file do I
> > need to poke at in GCC to convince it otherwise, at least on Debian/NetBSD
> > systems?
> 
> As the starting point, you need to verify that unix really isn't
> defined.

See above.

> If so, you need to inspect config/netbsd* and config/i386/netbsd* (and
> their includes); take particular notice of
> NETBSD_OS_CPP_BUILTINS_COMMON.
>
> > I'm also wondering just what is up with the -A flags, and what suitable
> > values for those are...
> 
> What do you mean, "is up"? They are assertions, for use with the
> #QUESTION preprocessor mechanism. While this is potentially very
> powerful, it is not used widely.
> 
> Regards,
> Martin

Mostly not being familiar with their usage, and wondering if those are
sane values. I had no intention of poking at them without knowing. Just
curiosity.

Next stupid question: which standard covers 'unix', so that I can make sure
all the pieces are met and that I'm not about to force GCC to tell a lie
that will come back to haunt me later...
-- 
***************************************************************************
Joel Baker                           System Administrator - lightbearer.com
lucifer@lightbearer.com              http://users.lightbearer.com/lucifer/

Attachment: pgpbZM_5D1O2I.pgp
Description: PGP signature


Reply to: