]> Savannah Git Hosting - gnulib.git/commitdiff
stdlib: Avoid syntax errors in libstdc++ header files.
authorBruno Haible <bruno@clisp.org>
Sun, 14 Jul 2024 18:45:46 +0000 (20:45 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 14 Jul 2024 18:45:46 +0000 (20:45 +0200)
* lib/stdlib.in.h: Include <string> before strtol, strtoll, strtoul, or
strtoull gets defined as a macro.

ChangeLog
lib/stdlib.in.h

index 6bca856db2d576e008c28df66b4ff4696f321e1f..0e09503f447f934bca586722d49a45c00bea2dac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-07-14  Bruno Haible  <bruno@clisp.org>
+
+       stdlib: Avoid syntax errors in libstdc++ header files.
+       * lib/stdlib.in.h: Include <string> before strtol, strtoll, strtoul, or
+       strtoull gets defined as a macro.
+
 2024-07-14  Bruno Haible  <bruno@clisp.org>
 
        Activate strtold workarounds.
index 47a8856dc75fcbb6dcbbf586cff7ee079b04ad7b..ac328eb5e74fa645422fe22e9af44a2f5d34afa7 100644 (file)
@@ -117,6 +117,16 @@ struct random_data
 # include <unistd.h>
 #endif
 
+#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__
+/* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro
+   below, this may cause compilation errors later in the libstdc++ header files
+   (that are part of GCC), such as:
+     error: 'rpl_strtol' is not a member of 'std'
+   To avoid this, include the relevant header files here, before these symbols
+   get defined as macros.  */
+# include <string>
+#endif
+
 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
    that can be freed by passing them as the Ith argument to the
    function F.  */