[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
snippet/warn-on-use: Fix compilation error in C++ mode on OpenBSD 7.0
From: |
Bruno Haible |
Subject: |
snippet/warn-on-use: Fix compilation error in C++ mode on OpenBSD 7.0 |
Date: |
Tue, 21 Dec 2021 15:11:17 +0100 |
On OpenBSD 7.0, with a clang-11.1 based C++ compiler, a gnulib testdir fails
to compile:
c++ -ferror-limit=0 -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
-I/usr/local/include -Wall -Wno-error -g -O2 -MT test-math-c++.o -MD -MP -MF
$depbase.Tpo -c -o test-math-c++.o ../../gltests/test-math-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-math-c++.cc:22:
In file included from ../gllib/math.h:41:
In file included from /usr/include/c++/v1/math.h:308:
In file included from ../gllib/stdlib.h:46:
../gllib/sys/wait.h:601:19: error: declaration of 'waitpid' has a different
language linkage
_GL_CXXALIASWARN (waitpid);
^
/usr/include/sys/wait.h:95:7: note: previous declaration is here
pid_t waitpid(pid_t, int *, int);
^
In file included from ../../gltests/test-math-c++.cc:22:
In file included from ../gllib/math.h:41:
In file included from /usr/include/c++/v1/math.h:308:
In file included from ../gllib/stdlib.h:100:
../gllib/unistd.h:787:19: error: declaration of 'access' has a different
language linkage
_GL_CXXALIASWARN (access);
^
/usr/include/unistd.h:325:6: note: previous declaration is here
int access(const char *, int);
^
In file included from ../../gltests/test-math-c++.cc:22:
In file included from ../gllib/math.h:41:
In file included from /usr/include/c++/v1/math.h:308:
In file included from ../gllib/stdlib.h:100:
../gllib/unistd.h:824:19: error: declaration of 'chdir' has a different
language linkage
_GL_CXXALIASWARN (chdir);
^
/usr/include/unistd.h:327:6: note: previous declaration is here
int chdir(const char *);
^
...
This patch fixes it.
2021-12-21 Bruno Haible <bruno@clisp.org>
snippet/warn-on-use: Fix compilation error in C++ mode on OpenBSD 7.0.
* lib/warn-on-use.h (_GL_WARN_ON_USE): In C++ mode, declare function
with "C" linkage.
diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h
index 612937abb..398429461 100644
--- a/lib/warn-on-use.h
+++ b/lib/warn-on-use.h
@@ -84,20 +84,20 @@
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
-extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
+_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__
(message)))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__warning__ (message)))
# elif __clang_major__ >= 4
/* Another compiler attribute is available in clang. */
# define _GL_WARN_ON_USE(function, message) \
-extern __typeof__ (function) function \
+_GL_WARN_EXTERN_C __typeof__ (function) function \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
__attribute__ ((__diagnose_if__ (1, message, "warning")))
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
/* Verify the existence of the function. */
# define _GL_WARN_ON_USE(function, message) \
-extern __typeof__ (function) function
+_GL_WARN_EXTERN_C __typeof__ (function) function
# define _GL_WARN_ON_USE_ATTRIBUTE(message)
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- snippet/warn-on-use: Fix compilation error in C++ mode on OpenBSD 7.0,
Bruno Haible <=