Define GNULIB_NAMESPACE in unittests/string_view-selftests.c
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 8 May 2018 20:45:02 +0000 (16:45 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Tue, 8 May 2018 20:45:02 +0000 (16:45 -0400)
When building with x86_64-w64-mingw32-g++ (to test cross-compiling for
Windows), I get this error:

unittests/string_view-selftests.o: In function `selftests::string_view::inserters_2::test05(unsigned long long)':
/home/emaisin/src/binutils-gdb/gdb/unittests/basic_string_view/inserters/char/2.cc:60: undefined reference to `std::basic_ofstream<char, std::char_traits<char> >::rpl_close()'

This is caused by gnulib redefining "close" as "rpl_close", and
therefore messing up the declaration of basic_ofstream in the libstdc++
header.  The solution would be to use gnulib namespaces [1].  Until we
use them across GDB, we can use them locally in files that are
problematic, like this one.

gdb/ChangeLog:

* unittests/string_view-selftests.c: Define GNULIB_NAMESPACE.

gdb/ChangeLog
gdb/unittests/string_view-selftests.c

index 8314945f1c7358579bf96741e90f5393cb71ee8d..a1059aef8d777882eab47dc74decfad4f85486cd 100644 (file)
@@ -1,3 +1,7 @@
+2018-05-08  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * unittests/string_view-selftests.c: Define GNULIB_NAMESPACE.
+
 2018-05-08  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * common/x86-xstate.h (I387_FCTRL_INIT_VAL): New constant.
index 182a5df9e4d3ffa5dd9d461403b4540063eb3323..55ffe640bf6bd1f09fc02c91dd7bb9f03bbadb8d 100644 (file)
@@ -21,6 +21,8 @@
    the "real" version.  */
 #if __cplusplus < 201703L
 
+#define GNULIB_NAMESPACE gnulib
+
 #include "defs.h"
 #include "selftest.h"
 #include "common/gdb_string_view.h"