include-file unhappiness - Mailing list pgsql-hackers

From Tom Lane
Subject include-file unhappiness
Date
Msg-id 20269.915411312@sss.pgh.pa.us
Whole thread Raw
Responses Re: [HACKERS] include-file unhappiness  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
I've been tweaking the current sources to make them compile on HPUX 9
again (right now they don't, for lack of vsnprintf() in libc).  All
went well until I tried to get rid of gcc's compile warnings about
lack of a prototype for snprintf & vsnprintf.  I put

#ifndef HAVE_SNPRINTF
extern int snprintf(char *str, size_t count, const char *fmt, ...);
#endif

#ifndef HAVE_VSNPRINTF
extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif

into include/c.h (they can't readily go into config.h because config.h
doesn't include any system header that defines size_t or va_list).

That almost works, but there are a few files that blow up because
they include c.h without having included config.h beforehand.

Now I maintain that every file that uses *any* of the Postgres
include files ought to include config.h.  Not doing so is a recipe
for trouble as we become more and more dependent on autoconf.
So I propose changing these files to include postgres.h instead of
just including c.h directly:

contrib/fulltextindex/fti.c
src/backend/port/dynloader/aix.c
src/backend/port/dynloader/hpux.c
src/backend/port/dynloader/ultrix4.c
src/backend/storage/buffer/s_lock.c
src/backend/utils/error/format.c
src/backend/utils/mmgr/oset.c
src/backend/utils/mmgr/palloc.c
src/include/libpq/pqcomm.h
src/interfaces/libpq/pqsignal.h

Any objections?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Oleg Broytmann
Date:
Subject: Re: Date/time fixes for HAVE_TM_ZONE platforms
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] include-file unhappiness