libintl.h not namespace clean in C++ mode
GOTO Masanori
gotom@debian.or.jp
Tue Jul 20 17:58:00 GMT 2004
At Thu, 3 Jun 2004 13:49:58 +0200,
Bruno Haible wrote:
> Here is a bug in libintl.h, reported by Herbert Straub <herbert@linuxhacker.at>:
> After #including <libintl.h> it is not possible to define member functions
> called 'gettext()'.
>
> Example:
> ======================= t0.cxx =========================
> #include <libintl.h>
> #include <string>
>
> class foo
> {
> std::string s;
> public:
> foo (const char *a) : s(a) {}
> std::string gettext (void) { return s; }
> };
> =========================================================
> $ g++-3.2.2 -O -c t0.cxx
> t0.cxx:9: parse error before `,' token
> t0.cxx:9: `std::string dcgettext' redeclared as different kind of symbol
> /usr/include/libintl.h:52: previous declaration of `char* dcgettext(const char*, const char*, int)'
> t0.cxx:9: syntax error before `{' token
> t0.cxx:10: parse error before `}' token
> $ g++-3.4.0 -O -c t0.cxx
> t0.cxx:9: error: expected `;' before '(' token
> t0.cxx:10: error: expected `;' before '}' token
>
> Here is a fix.
Looking at this patch, I wonder this patch makes header more complex.
Here's my version. Is this appliable?
Regards,
-- gotom
2004-07-21 GOTO Masanori <gotom@debian.or.jp>
* intl/libintl.h: Don't use optimizing gettext definition in C++ mode.
Index: intl/libintl.h
===================================================================
RCS file: /cvs/glibc/libc/intl/libintl.h,v
retrieving revision 1.25
diff -u -r1.25 libintl.h
--- intl/libintl.h 27 Jul 2002 08:37:07 -0000 1.25
+++ intl/libintl.h 20 Jul 2004 17:57:35 -0000
@@ -1,5 +1,5 @@
/* Message catalogs for internationalization.
- Copyright (C) 1995-1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1995-1999, 2000-2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This file is derived from the file libgettext.h in the GNU gettext package.
@@ -92,7 +92,7 @@
/* Optimized version of the function above. */
-#if defined __OPTIMIZE__
+#if defined __OPTIMIZE__ && !__cplusplus
/* We need NULL for `gettext'. */
# define __need_NULL
More information about the Libc-alpha
mailing list