[PATCH] Missing config.h inclusion breaks 32-bit _LARGEFILE64_SOURCE compilation --with-zlib

Nix nix at esperi.org.uk
Wed Nov 23 18:48:23 CET 2011


When building a 32-bit gnutls, when _LARGEFILE64_SOURCE is set in CFLAGS
and _FILE_OFFSET_BITS=64 is not, and zlib is built in, we see this
failure:

In file included from ../gnutls_compress.h:45:0,
                 from ../gnutls_int.h:300,
                 from opencdk.h:31,
                 from dummy.c:4:
/usr/include/32/zlib.h:1583:30: error: conflicting types for 'gzseek64'
/usr/include/32/zlib.h:1567:30: note: previous declaration of 'gzseek64' was here
/usr/include/32/zlib.h:1584:30: error: conflicting types for 'gztell64'
/usr/include/32/zlib.h:1568:30: note: previous declaration of 'gztell64' was here
/usr/include/32/zlib.h:1585:30: error: conflicting types for 'gzoffset64'
/usr/include/32/zlib.h:1569:30: note: previous declaration of 'gzoffset64' was here
/usr/include/32/zlib.h:1586:28: error: conflicting types for 'adler32_combine64'
/usr/include/32/zlib.h:1570:26: note: previous declaration of 'adler32_combine64' was here
/usr/include/32/zlib.h:1587:28: error: conflicting types for 'crc32_combine64'
/usr/include/32/zlib.h:1571:26: note: previous declaration of 'crc32_combine64' was here

This is because dummy.c does not include config.h early enough (which
defines _FILE_OFFSET_BITS=64 in this situation): thus, we end up with
z_off_t and z_off64_t as two distinct types, yet _FILE_OFFSET_BITS=64
also set. This leads to two distinct definitions of gzseek64() et al,
and compilation fails.

(If we could rely on using GCC, we could use -include to avoid this
error-prone include-at-the-top-of-every-file stuff. But we can't,
so we can't.)
---
 lib/opencdk/dummy.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Applies to 2.12.x, 3.0.x, and master.

diff --git a/lib/opencdk/dummy.c b/lib/opencdk/dummy.c
index be44a35..dd54dda 100644
--- a/lib/opencdk/dummy.c
+++ b/lib/opencdk/dummy.c
@@ -1,3 +1,6 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <stdio.h>
 #include <string.h>
 
-- 
1.7.7.2.144.g3624f




More information about the Gnutls-devel mailing list