Re: darwin pgsql patches - Mailing list pgsql-patches

From Tom Lane
Subject Re: darwin pgsql patches
Date
Msg-id 16592.975778254@sss.pgh.pa.us
Whole thread Raw
In response to Re: darwin pgsql patches  (Peter Bierman <bierman@apple.com>)
Responses Re: darwin pgsql patches
Re: darwin pgsql patches
List pgsql-patches
Peter Bierman <bierman@apple.com> writes:
> But I don't actually think it should. It's the prupose of configure,
> not the compiler, to determine the system that's running. Why should
> the compiler care what varriant of an OS it's running on? It might not
> even be compiling code for that OS.

Yeah, but header files care, and predefined symbols are the only way
that the C compiler can pass what it knows about the target environment
(which it *must* know about, in some fashion) to header files.
To take one example, what if a header file needs to know whether it's
being compiled under Rhapsody or Darwin?

> Is there some cost of #define __darwin__ in src/template/darwin that
> I'm not seeing? (not trying to be inflamatory here. :-)

I was just reminded of another reason why we like compiler-provided
symbols of this kind better than hacking one up in the port's header
file: you don't have to be very careful about whether such a symbol
is defined yet or not.  For example, our config.h has

/*
 * Define this if your operating system supports AF_UNIX family sockets.
 */
#if !defined(__CYGWIN__) && !defined(__QNX__) && !defined(__BEOS__)
# define HAVE_UNIX_SOCKETS 1
#endif

which works fine, but only because those are all compiler-predefined
symbols --- the port-specific os.h file hasn't been included yet.
("Rearrange the code" isn't a very good retort, because that just
introduces other ordering problems.)

You might want to think about having the template/darwin file add
-D__darwin__ to CPPFLAGS, instead of putting a #define in port/darwin.h.
And have another go at convincing Apple that they're wrong not to have
their compiler provide such a symbol automatically.

            regards, tom lane

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: darwin pgsql patches
Next
From: Peter Bierman
Date:
Subject: Re: darwin pgsql patches