The file "postgres.h" (or "c.h" or "config.h", whatever is used) needs to
be the very *first* file included by each source file.  Next time you
touch a source file, please check that this is the case.

The obvious failure mode is that if config.h redefines const, volatile, or
inline then it will cause confusion when some system headers are included
before and some after that definition.

The slightly more esoteric problem I encountered is that when you compile
with CC='gcc -std=c99 -pedantic' on a glibc platform (i.e., "Linux") then
you need to define _SVID_SOURCE and _BSD_SOURCE before including any
system header in order to get the full feature set from the headers.

(Unfortunately, the flex output does not observe this rule either, so we
can't be 100% pedantic warning safe without doing surgery on those files.)

On a related note, does anyone know why the on_proc_exit and on_shmem_exit
hooks use a second argument of type `caddr_t' rather than, say, void*,
char*, Datum, ...?  This artifact is the cause of about two thirds of the
compile errors in the pedantic setting.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


Mon, 2 Oct 2000 11:47:48 +0200 (CEST)
Peter Eisentraut <peter_e@gmx.net>
Note about include files
* Peter Eisentraut <peter_e@gmx.net> [001002 02:51] wrote:
> The file "postgres.h" (or "c.h" or "config.h", whatever is used) needs to
> be the very *first* file included by each source file.  Next time you
> touch a source file, please check that this is the case.
> 
> The obvious failure mode is that if config.h redefines const, volatile, or
> inline then it will cause confusion when some system headers are included
> before and some after that definition.
> 
> The slightly more esoteric problem I encountered is that when you compile
> with CC='gcc -std=c99 -pedantic' on a glibc platform (i.e., "Linux") then
> you need to define _SVID_SOURCE and _BSD_SOURCE before including any
> system header in order to get the full feature set from the headers.
> 
> (Unfortunately, the flex output does not observe this rule either, so we
> can't be 100% pedantic warning safe without doing surgery on those files.)

gcc supports the '-include' directive which may be what you want.

-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

Mon, 2 Oct 2000 02:58:38 -0700
Alfred Perlstein <bright@wintelcom.net>
Re: Note about include files
Peter Eisentraut <peter_e@gmx.net> writes:
> On a related note, does anyone know why the on_proc_exit and on_shmem_exit
> hooks use a second argument of type `caddr_t' rather than, say, void*,
> char*, Datum, ...?  This artifact is the cause of about two thirds of the
> compile errors in the pedantic setting.

I was annoyed by that just the other day on an Alpha box (it provokes
lots of "integer cast to pointer of different size" warnings there).
I'm sure the use of caddr_t is strictly historical.

If you feel like doing something about it, changing the arguments of
these routines to be Datum and then adding the necessary
to-and-from-Datum macros seems like the obvious solution path.

			regards, tom lane

Mon, 02 Oct 2000 10:45:03 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Note about include files 
> The file "postgres.h" (or "c.h" or "config.h", whatever is used) needs to
> be the very *first* file included by each source file.  Next time you
> touch a source file, please check that this is the case.
> 
> The obvious failure mode is that if config.h redefines const, volatile, or
> inline then it will cause confusion when some system headers are included
> before and some after that definition.
> 
> The slightly more esoteric problem I encountered is that when you compile
> with CC='gcc -std=c99 -pedantic' on a glibc platform (i.e., "Linux") then
> you need to define _SVID_SOURCE and _BSD_SOURCE before including any
> system header in order to get the full feature set from the headers.
> 
> (Unfortunately, the flex output does not observe this rule either, so we
> can't be 100% pedantic warning safe without doing surgery on those files.)
> 
> On a related note, does anyone know why the on_proc_exit and on_shmem_exit
> hooks use a second argument of type `caddr_t' rather than, say, void*,
> char*, Datum, ...?  This artifact is the cause of about two thirds of the
> compile errors in the pedantic setting.

That was me.  caddr_t was I used for function pointers.  Glad you
changed it.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Sun, 8 Oct 2000 00:28:07 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Note about include files]