* [PATCH] PR libstdc++/85729 add linkage specifications to headers
@ 2018-05-10 12:35 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2018-05-10 12:35 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 437 bytes --]
This works around user error where our headers get included within an
extern "C" block.
PR libstdc++/85729
* include/bits/c++config.h (__replacement_assert): Add linkage
specification.
* include/bits/std_abs.h: Add comment to closing brace of block.
* include/c_global/cstddef: Add linkage specification.
* include/c_global/cstring: Likewise.
* include/c_global/cwchar: Likewise.
Tested powerpc64le-linux, committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3167 bytes --]
commit 72a9c99cc1fc94c6b4c1fbe2ae223d07237a817e
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu May 10 12:50:55 2018 +0100
PR libstdc++/85729 add linkage specifications to headers
PR libstdc++/85729
* include/bits/c++config.h (__replacement_assert): Add linkage
specification.
* include/bits/std_abs.h: Add comment to closing brace of block.
* include/c_global/cstddef: Add linkage specification.
* include/c_global/cstring: Likewise.
* include/c_global/cwchar: Likewise.
diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index bfe268da825..280f65e1ba0 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -438,7 +438,7 @@ namespace std
{
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
- inline void
+ extern "C++" inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
diff --git a/libstdc++-v3/include/bits/std_abs.h b/libstdc++-v3/include/bits/std_abs.h
index 6e4551d6597..bcea4f49203 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -105,6 +105,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
-}
+} // extern "C"++"
#endif // _GLIBCXX_BITS_STD_ABS_H
diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef
index 36d7d716cc3..0ca3b82338a 100644
--- a/libstdc++-v3/include/c_global/cstddef
+++ b/libstdc++-v3/include/c_global/cstddef
@@ -49,13 +49,15 @@
#include <bits/c++config.h>
#include <stddef.h>
+extern "C++"
+{
#if __cplusplus >= 201103L
namespace std
{
// We handle size_t, ptrdiff_t, and nullptr_t in c++config.h.
using ::max_align_t;
}
-#endif
+#endif // C++11
#if __cplusplus >= 201703L
namespace std
@@ -186,6 +188,7 @@ namespace std
{ return _IntegerType(__b); }
} // namespace std
-#endif
+#endif // C++17
+} // extern "C++"
#endif // _GLIBCXX_CSTDDEF
diff --git a/libstdc++-v3/include/c_global/cstring b/libstdc++-v3/include/c_global/cstring
index 399f41fb164..2bca01b7f08 100644
--- a/libstdc++-v3/include/c_global/cstring
+++ b/libstdc++-v3/include/c_global/cstring
@@ -68,6 +68,8 @@
#undef strtok
#undef strxfrm
+extern "C++"
+{
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -119,5 +121,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
+} // extern "C++"
#endif
diff --git a/libstdc++-v3/include/c_global/cwchar b/libstdc++-v3/include/c_global/cwchar
index 475322ee806..7557c7768aa 100644
--- a/libstdc++-v3/include/c_global/cwchar
+++ b/libstdc++-v3/include/c_global/cwchar
@@ -132,6 +132,8 @@ namespace std
#if _GLIBCXX_USE_WCHAR_T
+extern "C++"
+{
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -231,6 +233,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
+} // extern "C++"
#if _GLIBCXX_USE_C99_WCHAR
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-10 12:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-10 12:35 [PATCH] PR libstdc++/85729 add linkage specifications to headers Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).