Lucas Standaert
2004-Feb-05 00:21 UTC
anyone else have a <sys/stat.h> that DOESN'T #include <sys/types.h> ?
I'm porting openssh 3.7.1p2 to a very BSD 4.4-ish system. My first hint of a problem was that configure said it couldn't find <sys/types.h> and that the sizes of char, int, etc were 0 (zero). It turned out that "confdefs.h" had HAVE_SYS_STAT_H defined, but not HAVE_SYS_TYPES_H, resulting in code such as the following to fail to compile on a system where sys/stat.h does NOT include sys/types.h: ac_includes_default="\ #include <stdio.h> #if HAVE_SYS_TYPES_H # include <sys/types.h> #endif #if HAVE_SYS_STAT_H # include <sys/stat.h> #endif ... I can't figure out where HAVE_SYS_STAT_H gets added to confdefs.h by configure, so I worked around the problem by adding this flag to the configure invocation: --with-cflags="-DHAVE_SYS_TYPES_H=1" I see that NetBSD added #include <sys/types.h> to sys/stat.h somewhere between releases 1.3 and 1.4. Anyone else out there using headers old enough to hit this problem? Thanks, Lucas
Darren Tucker
2004-Feb-05 05:18 UTC
anyone else have a <sys/stat.h> that DOESN'T #include <sys/types.h> ?
Lucas Standaert wrote:> I'm porting openssh 3.7.1p2 to a very BSD 4.4-ish system. My first > hint of a problem was that configure said it couldn't find <sys/types.h> > and that the sizes of char, int, etc were 0 (zero). It turned > out that "confdefs.h"Do you mean config.h not confdefs.h? > had HAVE_SYS_STAT_H defined, but not HAVE_SYS_TYPES_H,> resulting in code such as the following to fail to compile on > a system where sys/stat.h does NOT include sys/types.h: > > ac_includes_default="\ > #include <stdio.h> > #if HAVE_SYS_TYPES_H > # include <sys/types.h> > #endif > #if HAVE_SYS_STAT_H > # include <sys/stat.h> > #endifYou might also try regenerating configure with autoconf. Different versions of autoconf behave slightly differently on different platforms. OpenSSH currently uses 2.52 with a couple of mods (which is somewhat old, but it works properly on most of the platforms we know about).> I can't figure out where HAVE_SYS_STAT_H gets added to confdefs.h > by configure, so I worked around the problem by adding this > flag to the configure invocation:It's added by the part of configure generated by this fragment of configure.ac: # Checks for header files. AC_CHECK_HEADERS([...] sys/stat.h [...]) -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.