Обсуждение: compile problem in libpq
I had t add a #include <sys/time.h> to get fe-misc.c to compile on my Debian GNU/Linux 2.0 machine. Michael -- Dr. Michael Meskes, Project-Manager | topsystem Systemhaus GmbH meskes@topsystem.de | Europark A2, Adenauerstr. 20 meskes@debian.org | 52146 Wuerselen Go SF49ers! Go Rhein Fire! | Tel: (+49) 2405/4670-44 Use Debian GNU/Linux! | Fax: (+49) 2405/4670-10
> > I had t add a #include <sys/time.h> to get fe-misc.c to compile on my Debian > GNU/Linux 2.0 machine. > Do you have the #include <time.h> line, and you need sys/time.h too? -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
>> I had t add a #include <sys/time.h> to get fe-misc.c to compile on my Debian
>> GNU/Linux 2.0 machine.
> Do you have the #include <time.h> line, and you need sys/time.h too?
Now that he mentions it, I've seen the same thing on Linux boxen:
you need to include both <time.h> and <sys/time.h>. (I think the
latter pulls in some definitions needed to use select() on that OS.)
Sorry for not remembering about it. On my OS <time.h> just includes
<sys/time.h> ...
The Autoconf manual says:
- Macro: AC_HEADER_TIME
If a program may include both `time.h' and `sys/time.h', define
`TIME_WITH_SYS_TIME'. On some older systems, `sys/time.h'
includes `time.h', but `time.h' is not protected against multiple
inclusion, so programs should not explicitly include both files.
This macro is useful in programs that use, for example, `struct
timeval' or `struct timezone' as well as `struct tm'. It is best
used in conjunction with `HAVE_SYS_TIME_H', which can be checked
for using `AC_CHECK_HEADERS(sys/time.h)'.
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
I notice that configure.in invokes AC_HEADER_TIME, but does not check
for existence of <sys/time.h> ... and neither of these symbols are
getting exported into config.h anyway. But that's probably the most
robust advice you're going to find.
regards, tom lane
> > >> I had t add a #include <sys/time.h> to get fe-misc.c to compile on my Debian > >> GNU/Linux 2.0 machine. > > > Do you have the #include <time.h> line, and you need sys/time.h too? > > Now that he mentions it, I've seen the same thing on Linux boxen: > you need to include both <time.h> and <sys/time.h>. (I think the > latter pulls in some definitions needed to use select() on that OS.) > Sorry for not remembering about it. On my OS <time.h> just includes > <sys/time.h> ... OK, I added sys/time.h to fe-misc.c postmaster.c has time.h and sys/time.h, so why not here too? -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)