[PATCH] #undef isblank before def or decl in libstdc++ headers
Jonathan Wakely
jwakely@redhat.com
Fri Dec 10 18:24:18 GMT 2021
On Fri, 10 Dec 2021 at 17:07, Olivier Hainque via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Hello,
>
> The attached patch helps fix a build failure of libstdc++
> on some variants of VxWorks where the system headers expose
> an "isblank" macro.
>
> I understand this kind of thing normally is handled through
> fixincludes, however fixincludes on VxWorks is very tricky and
> we already have
>
> libstdc++-v3/include/c_global/cctype:#undef isblank
> libstdc++-v3/include/tr1/cctype:#undef isblank
>
> so the suggestion here is to simply do the same in a couple
> more places.
Both of those places already include <cctype> so I think we should just do this:
--- a/libstdc++-v3/include/c_global/cctype
+++ b/libstdc++-v3/include/c_global/cctype
@@ -78,10 +78,10 @@ namespace std
#if __cplusplus >= 201103L
-#ifdef _GLIBCXX_USE_C99_CTYPE_TR1
-
#undef isblank
+#ifdef _GLIBCXX_USE_C99_CTYPE_TR1
+
namespace std
{
using ::isblank;
I'm curious why _GLIBCXX_USE_C99_CTYPE_TR1 is not defined if VxWorks
has isblank, the configure check is:
# Check for the existence of <ctype.h> functions.
AC_CACHE_CHECK([for ISO C99 support to TR1 in <ctype.h>],
glibcxx_cv_c99_ctype_tr1, [
AC_TRY_COMPILE([#include <ctype.h>],
[int ch;
int ret;
ret = isblank(ch);
],[glibcxx_cv_c99_ctype_tr1=yes],
[glibcxx_cv_c99_ctype_tr1=no])
])
if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
[Define if C99 functions in <ctype.h> should be imported in
<tr1/cctype> in namespace std::tr1.])
fi
In any case, undef'ing it unconditionally in <cctype> should work, and
avoids having to do it in multiple places (we still need it in
<tr1/cctype> because that is used in C++98 code, whereas the other
definitions of functions called "isblank" were added for C++11).
More information about the Gcc-patches
mailing list