[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ compilation errors in wchar.h
From: |
Bruno Haible |
Subject: |
Re: C++ compilation errors in wchar.h |
Date: |
Sat, 2 Apr 2011 00:02:09 +0200 |
User-agent: |
KMail/1.9.9 |
Bruce Korb wrote:
> /bin/sh ../libtool --tag=CC --preserve-dup-deps --mode=link gcc -std=gnu99
> -g -O2 -o test-vsprintf-posix test-vsprintf-posix.o libtests.a
> ../lib/libposix.la libtests.a
> libtool: link: gcc -std=gnu99 -g -O2 -o .libs/test-vsprintf-posix
> test-vsprintf-posix.o libtests.a ../lib/.libs/libposix.so -lrt -lm
> libtests.a -Wl,-rpath
> -Wl,/old-home/gnu/proj/gnulib-posix/libposix/_b/libposix-0.0.5093-16648/_inst/lib
> depbase=`echo test-wchar-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> g++ -DHAVE_CONFIG_H -I. -I../../tests -I.. -DIN_LIBPOSIX_GNULIB_TESTS=1 -I.
> -I../../tests -I.. -I../../tests/.. -I../lib -I../../tests/../lib -MT
> test-wchar-c++.o -MD -MP -MF $depbase.Tpo -c -o test-wchar-c++.o
> ../../tests/test-wchar-c++.cc &&\
> mv -f $depbase.Tpo $depbase.Po
> In file included from ../../tests/test-wchar-c++.cc:22:0:
> ../lib/wchar.h:750:1: error: no matches converting function 'wmemchr' to type
> 'wchar_t* (*)(const wchar_t*, wchar_t, size_t)'
> /usr/include/wchar.h:311:23: error: candidates are: wchar_t*
> wmemchr(wchar_t*, wchar_t, size_t)
> /usr/include/wchar.h:313:31: error: const wchar_t*
> wmemchr(const wchar_t*, wchar_t, size_t)
> ../lib/wchar.h:751:1: error: type of 'wmemchr' is unknown
> ../lib/wchar.h:751:27: error: invalid type in declaration before ';' token
> ../lib/wchar.h:751:27: error: 'int wmemchr' redeclared as different kind of
> symbol
> /usr/include/wchar.h:313:31: error: previous declaration of 'const wchar_t*
> wmemchr(const wchar_t*, wchar_t, size_t)'
> ../lib/wchar.h:1176:1: error: no matches converting function 'wcsstr' to type
> 'wchar_t* (*)(const wchar_t*, const wchar_t*)'
> /usr/include/wchar.h:268:23: error: candidates are: wchar_t* wcsstr(wchar_t*,
> const wchar_t*)
> /usr/include/wchar.h:270:31: error: const wchar_t*
> wcsstr(const wchar_t*, const wchar_t*)
> ../lib/wchar.h:1178:1: error: type of 'wcsstr' is unknown
> ../lib/wchar.h:1178:26: error: invalid type in declaration before ';' token
> ../lib/wchar.h:1178:26: error: 'int wcsstr' redeclared as different kind of
> symbol
> /usr/include/wchar.h:270:31: error: previous declaration of 'const wchar_t*
> wcsstr(const wchar_t*, const wchar_t*)'
> make[5]: *** [test-wchar-c++.o] Error 1
This appears to be a glibc >= 2.10 platform, right? I reproduce it on a RHEL 6
system.
The issue appears to be the same as the two problems in
<http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00113.html>
<http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00125.html>
and is caused by this commit in glibc:
<http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d8387c7b7b1c9ae92f924c33ba05790c98464d19>
I'm committing this fix:
2011-04-01 Bruno Haible <address@hidden>
wmemchr, wcschr, wcsrchr, wcspbrk, wcsstr: Avoid errors in C++ mode.
* lib/wchar.in.h (wmemchr, wcschr, wcsrchr, wcspbrk, wcsstr): Use
_GL_CXXALIAS_SYS_CAST2 instead of _GL_CXXALIAS_SYS. On glibc >= 2.10
systems, use _GL_CXXALIASWARN1 instead of _GL_CXXALIASWARN.
Reported by Bruce Korb <address@hidden>.
--- lib/wchar.in.h.orig Fri Apr 1 23:57:17 2011
+++ lib/wchar.in.h Fri Apr 1 23:55:13 2011
@@ -435,8 +435,22 @@
# if address@hidden@
_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
# endif
-_GL_CXXALIAS_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
+ wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wmemchr,
+ wchar_t *, (const wchar_t *, wchar_t, size_t),
+ const wchar_t *, (const wchar_t *, wchar_t, size_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
+ (const wchar_t *s, wchar_t c, size_t n));
+# else
_GL_CXXALIASWARN (wmemchr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wmemchr
# if HAVE_RAW_DECL_WMEMCHR
@@ -776,8 +790,21 @@
# if address@hidden@
_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
# endif
-_GL_CXXALIAS_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcschr (const wchar_t *, wchar_t);
+ wchar_t * std::wcschr (wchar_t *, wchar_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcschr,
+ wchar_t *, (const wchar_t *, wchar_t),
+ const wchar_t *, (const wchar_t *, wchar_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# else
_GL_CXXALIASWARN (wcschr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcschr
# if HAVE_RAW_DECL_WCSCHR
@@ -792,8 +819,21 @@
# if address@hidden@
_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
# endif
-_GL_CXXALIAS_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
+ wchar_t * std::wcsrchr (wchar_t *, wchar_t);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcsrchr,
+ wchar_t *, (const wchar_t *, wchar_t),
+ const wchar_t *, (const wchar_t *, wchar_t));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# else
_GL_CXXALIASWARN (wcsrchr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcsrchr
# if HAVE_RAW_DECL_WCSRCHR
@@ -843,9 +883,23 @@
_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
(const wchar_t *wcs, const wchar_t *accept));
# endif
-_GL_CXXALIAS_SYS (wcspbrk, wchar_t *,
- (const wchar_t *wcs, const wchar_t *accept));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
+ wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcspbrk,
+ wchar_t *, (const wchar_t *, const wchar_t *),
+ const wchar_t *, (const wchar_t *, const wchar_t *));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
+ (wchar_t *wcs, const wchar_t *accept));
+_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
+ (const wchar_t *wcs, const wchar_t *accept));
+# else
_GL_CXXALIASWARN (wcspbrk);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcspbrk
# if HAVE_RAW_DECL_WCSPBRK
@@ -861,9 +915,23 @@
_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
(const wchar_t *haystack, const wchar_t *needle));
# endif
-_GL_CXXALIAS_SYS (wcsstr, wchar_t *,
- (const wchar_t *haystack, const wchar_t *needle));
+ /* On some systems, this function is defined as an overloaded function:
+ extern "C++" {
+ const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
+ wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
+ } */
+_GL_CXXALIAS_SYS_CAST2 (wcsstr,
+ wchar_t *, (const wchar_t *, const wchar_t *),
+ const wchar_t *, (const wchar_t *, const wchar_t *));
+# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
+ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
+ (wchar_t *haystack, const wchar_t *needle));
+_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
+ (const wchar_t *haystack, const wchar_t *needle));
+# else
_GL_CXXALIASWARN (wcsstr);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef wcsstr
# if HAVE_RAW_DECL_WCSSTR
--
In memoriam Karim Mohammedzadeh
<http://en.wikipedia.org/wiki/Karim_Mohammedzadeh>