fcntl-h: Fix for use of C++ on glibc systems.
authorBruno Haible <bruno@clisp.org>
Sat, 25 Dec 2010 13:43:05 +0000 (14:43 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 25 Dec 2010 13:43:05 +0000 (14:43 +0100)
* lib/fcntl.in.h: Include <sys/stat.h> before include_next <fcntl.h>
also on glibc systems in C++ mode.
Reported by Gary V. Vaughan <gary@gnu.org>.

ChangeLog
lib/fcntl.in.h

index 441724b..5aaac69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-12-25  Bruno Haible  <bruno@clisp.org>
 
+       fcntl-h: Fix for use of C++ on glibc systems.
+       * lib/fcntl.in.h: Include <sys/stat.h> before include_next <fcntl.h>
+       also on glibc systems in C++ mode.
+       Reported by Gary V. Vaughan <gary@gnu.org>.
+
+2010-12-25  Bruno Haible  <bruno@clisp.org>
+
        roundl-ieee: Make it work on OSF/1 5.1 with cc.
        * modules/roundl-ieee (Depends-on): Add floorl-ieee, ceill-ieee.
 
index 6d1888d..73c5f1e 100644 (file)
 #ifndef _GL_FCNTL_H
 
 #include <sys/types.h>
-#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
+/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
+   <fcntl.h>.  On glibc systems, we would like to avoid namespace pollution.
+   But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
+   extern "C" { ... } block, which leads to errors in C++ mode with the
+   overridden <sys/stat.h> from gnulib.  These errors are known to be gone
+   with g++ version >= 4.3.  */
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
 # include <sys/stat.h>
 #endif
 /* The include_next requires a split double-inclusion guard.  */