[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix compilation error in C++ mode on OpenBSD
From: |
Bruno Haible |
Subject: |
fix compilation error in C++ mode on OpenBSD |
Date: |
Sun, 08 Dec 2019 22:53:54 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) |
On OpenBSD, a testdir created with --with-c++-tests produces this compilation
error:
depbase=`echo test-spawn-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; g++
-DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I../../gltests -I..
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I..
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -I/home/bruno/include
-Wall -MT test-spawn-c++.o -MD -MP -MF $depbase.Tpo -c -o test-spawn-c++.o
../../gltests/test-spawn-c++.cc && mv -f $depbase.Tpo $depbase.Po
In file included from ../gllib/sys/select.h:110,
from /usr/include/sys/time.h:38,
from ../gllib/sys/time.h:39,
from /usr/include/sys/siginfo.h:130,
from /usr/include/sys/signal.h:107,
from /usr/include/spawn.h:34,
from ../gllib/spawn.h:28,
from ../../gltests/test-spawn-c++.cc:22:
../gllib/signal.h: In member function 'gnulib::_gl_signal_wrapper::operator
void (* (*)(int, void (*)(int)))(int)() const':
../gllib/signal.h:799: error: '::signal' has not been declared
...
Build for test-spawn-c++ aborted
The reason is that
- On OpenBSD, signal() is declared near the end of <sys/signal.h>, not
in <signal.h>.
- <signal.h> includes <sys/signal.h>, but in this case, <spawn.h>
includes <sys/signal.h> directly, which has the effect that when <signal.h>
includes <sys/signal.h>, this include does nothing.
- Thus gnulib's <signal.h> use of ::signal occurs before the function gets
declared.
This patch fixes it.
2019-12-08 Bruno Haible <address@hidden>
Fix compilation error in C++ mode on OpenBSD.
* lib/signal.in.h (signal): Declare on OpenBSD.
diff --git a/lib/signal.in.h b/lib/signal.in.h
index b4e432d..5b36c25 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -322,6 +322,12 @@ _GL_FUNCDECL_RPL (signal,
_gl_function_taking_int_returning_void_t,
_GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t,
(int sig, _gl_function_taking_int_returning_void_t func));
# else
+/* On OpenBSD, the declaration of 'signal' may not be present at this point,
+ because it occurs in <sys/signal.h>, not <signal.h> directly. */
+# if defined __OpenBSD__
+_GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t,
+ (int sig, _gl_function_taking_int_returning_void_t func));
+# endif
_GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t,
(int sig, _gl_function_taking_int_returning_void_t func));
# endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fix compilation error in C++ mode on OpenBSD,
Bruno Haible <=