bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unistd: fix compilation error in C++ mode on MSVC


From: Bruno Haible
Subject: unistd: fix compilation error in C++ mode on MSVC
Date: Wed, 11 Dec 2019 11:40:54 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

When building a testdir with C++ tests on MSVC 14, I see this error:

source='../../gllib/faccessat.c' object='faccessat.obj' libtool=no \
DEPDIR=.deps depmode=msvc7 /bin/sh ../../build-aux/depcomp \
/home/bruno/msvc/compile cl -nologo -DHAVE_CONFIG_H -I. -I../../gllib -I..  
-DGNULIB_STRICT_CHECKING=1 -D_WIN32_WINNT=_WIN32_WINNT_WINXP 
-I/usr/local/msvc64/include  -MD -c -o faccessat.obj `cygpath -w 
'../../gllib/faccessat.c'`
faccessat.c
.\unistd.h(32): fatal error C1014: too many include files: depth = 1024
make[4]: *** [Makefile:3604: faccessat.obj] Error 2

The cause is that gnulib's unistd.h override essentially starts with

#ifdef _GL_INCLUDING_UNISTD_H
#include <unistd.h>
#else
...

and _GL_INCLUDING_UNISTD_H is defined by faccessat.c.

The second line
  - has #include, not #include_next, because MSVC does not support
    #include_next,
  - has <unistd.h>, not some absolute file name, because MSVC does not
    have <unistd.h>.
This combination leads to an endless recursion of includes.

This patch fixes it. It might not work well in projects which use
multiple gnulib checkouts on top of each other, but such a setup is
fragile anyway.


2019-12-11  Bruno Haible  <address@hidden>

        unistd: Fix compilation error in C++ mode on MSVC.
        * lib/unistd.in.h: Don't do include[_next] <unistd.h> if the platform
        does not have <unistd.h>.

diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 28ab704..269318e 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -21,7 +21,7 @@
 #endif
 @PRAGMA_COLUMNS@
 
-#ifdef _GL_INCLUDING_UNISTD_H
+#if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H
 /* Special invocation convention:
    - On Mac OS X 10.3.9 we have a sequence of nested includes
      <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]