[CCing bug-gnulib] Hi,
Christian Weisgerber wrote in <http://lists.gnu.org/archive/html/bug-gnu-utils/2010-06/msg00083.html>: > As seen on OpenBSD/sparc, the gettext-tools/tests/lang-c++ check > fails to compile with gcc2.95: > > In file included from ../gnulib-lib/sys/select.h:56, > from /usr/include/sys/types.h:224, > from /usr/include/stdio.h:45, > from ../gnulib-lib/stdio.h:35, > from prog.cc:13: > ../gnulib-lib/string.h:497: syntax error before `(' > ../gnulib-lib/string.h:587: syntax error before `(' > ../gnulib-lib/string.h:829: syntax error before `(' > FAIL: lang-c++ > > What happens is that declarations from gnulib-lib/string.in.h like > this one > > _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) > __attribute__ ((__pure__)) > _GL_ARG_NONNULL ((1))); > > after preprocessing end up as > > extern "C" void * rawmemchr (void const *__s, int __c_in) > __attribute__ (( )) > ; > > because __pure__ is defined away for gcc2.95. However, > __attribute__(( )) causes an error for C++ (but not for plain C). Thanks for the report. I'm applying this patch to gnulib (this is where the generated string.h comes from). The fix will automatically be included in gettext 0.18.2. 2010-06-29 Bruno Haible <br...@clisp.org> string: Fix syntax error with g++ 2.96. * lib/string.in.h (__pure__): Remove definition. (_GL_ATTRIBUTE_PURE): New macro. (memchr, memmem, memrchr, rawmemchr, strchrnul, strnlen, strpbrk, strstr, strcasestr): Use it instead of __attribute__ ((__pure__)). Reported by Christian Weisgerber <na...@mips.inka.de>. --- lib/string.in.h.orig Wed Jun 30 02:16:30 2010 +++ lib/string.in.h Wed Jun 30 02:16:22 2010 @@ -41,10 +41,12 @@ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) # define __attribute__(Spec) /* empty */ # endif +#endif /* The attribute __pure__ was added in gcc 2.96. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) -# define __pure__ /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ #endif @@ -62,13 +64,13 @@ # define memchr rpl_memchr # endif _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else # if ! @HAVE_MEMCHR@ _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -102,7 +104,8 @@ _GL_FUNCDECL_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len)); @@ -111,7 +114,8 @@ _GL_FUNCDECL_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); # endif _GL_CXXALIAS_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, @@ -152,7 +156,7 @@ #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -182,7 +186,7 @@ #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -272,7 +276,7 @@ #if @GNULIB_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -378,13 +382,13 @@ # define strnlen rpl_strnlen # endif _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); # else # if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); @@ -414,7 +418,7 @@ #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: @@ -514,7 +518,7 @@ # define strstr rpl_strstr # endif _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); # else @@ -556,14 +560,16 @@ # endif _GL_FUNCDECL_RPL (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strcasestr, char *, (const char *haystack, const char *needle)); # else # if ! @HAVE_STRCASESTR@ _GL_FUNCDECL_SYS (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * strcasestr (const char *, const char *); }