include-file unhappiness

Started by Tom Laneover 27 years ago2 messageshackers
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

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

#2Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#1)
Re: [HACKERS] include-file unhappiness

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

Go ahead. Good reasoning for doing this.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@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