PR gold/17473: Fix gold build with system C++ headers that use <ctype.h>.
authorRoland McGrath <mcgrathr@chromium.org>
Thu, 17 Dec 2015 00:35:27 +0000 (16:35 -0800)
committerRoland McGrath <mcgrathr@chromium.org>
Thu, 17 Dec 2015 00:35:27 +0000 (16:35 -0800)
gold/
PR gold/17473
* binary.cc: Move #include "safe-ctype.h" to be last #include.

gold/ChangeLog
gold/binary.cc

index 06608eb..d929cb7 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-16  Roland McGrath  <mcgrathr@google.com>
+
+       PR ld/17473
+       * binary.cc: Move #include "safe-ctype.h" to be last #include.
+
 2015-12-13  Cary Coutant  <ccoutant@gmail.com>
 
        * object.h (Object::get_output_view): remove const from return type.
@@ -25,7 +30,7 @@
        * object.h (Object::get_output_view): New function.
        (Object::do_get_output_view): New function.
        (Sized_relobj_file::do_get_output_view): New function.
-       (Sized_relobj_file::output_views_): New data member.    
+       (Sized_relobj_file::output_views_): New data member.
        * reloc.cc: (Sized_relobj_file::do_relocate): Store pointer to
        output views in class object.
        (Sized_relobj_file::do_get_output_view): New function.
index 12ca296..52df81a 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <cerrno>
 #include <cstring>
-#include "safe-ctype.h"
 
 #include "elfcpp.h"
 #include "stringpool.h"
 #include "output.h"
 #include "binary.h"
 
+// safe-ctype.h interferes with macros defined by the system <ctype.h>.
+// Some C++ system headers might include <ctype.h> and rely on its macro
+// definitions being intact.  So make sure that safe-ctype.h is included
+// only after any C++ system headers, whether directly here (above) or via
+// other local header files (e.g. #include <string> in "binary.h").
+#include "safe-ctype.h"
+
 // Support for reading binary files as input.  These become blobs in
 // the final output.  These files are treated as though they have a
 // single .data section and define three symbols: