Commit Message
ping
From: Wilco Dijkstra
Sent: 20 December 2016 15:37
To: libc-alpha@sourceware.org
Cc: nd
Subject: [PATCH] Fix C++ debug tests
The internal header include/string.h does not work in C++: it causes link errors
in several C++ debug tests when any of the functions it declares are called.
The best option would be to not use internal headers for tests (unless explicitly
needed). As a workaround for now, add extern "C" {} to the C++ debug tests.
C++ debug tests now build and pass.
ChangeLog:
2016-12-21 Wilco Dijkstra <wdijkstr@arm.com>
* debug/tst-chk4.cc: Add extern "C".
* debug/tst-chk5.cc: Likewise.
* debug/tst-chk6.cc: Likewise.
* debug/tst-lfschk4.cc: Likewise.
* debug/tst-lfschk5.cc: Likewise.
* debug/tst-lfschk6.cc: Likewise.
--
Comments
On Thu, 9 Feb 2017, Wilco Dijkstra wrote:
> The internal header include/string.h does not work in C++: it causes
> link errors in several C++ debug tests when any of the functions it
> declares are called. The best option would be to not use internal
> headers for tests (unless explicitly needed). As a workaround for now,
> add extern "C" {} to the C++ debug tests.
I think extern "C" belongs around specific declarations in headers, not
around whole source files. I'd suggest disabling the internal
declarations if __cplusplus instead (just as they are disabled for
_ISOMAC).
@@ -1 +1,3 @@
+extern "C" {
 #include "tst-chk1.c"
+}
@@ -1,2 +1,4 @@
+extern "C" {
 #define _FORTIFY_SOURCE 1
 #include "tst-chk1.c"
+}
@@ -1,2 +1,4 @@
+extern "C" {
 #define _FORTIFY_SOURCE 2
 #include "tst-chk1.c"
+}
@@ -1,2 +1,4 @@
+extern "C" {
 #define _FILE_OFFSET_BITS 64
 #include "tst-chk1.c"
+}
@@ -1,2 +1,4 @@
+extern "C" {
 #define _FILE_OFFSET_BITS 64
 #include "tst-chk2.c"
+}
@@ -1,2 +1,4 @@
+extern "C" {
 #define _FILE_OFFSET_BITS 64
 #include "tst-chk3.c"
+}