This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Prevent macro expansion of mblen
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Subject: Re: Prevent macro expansion of mblen
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 25 Dec 2000 19:11:28 -0200
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <Pine.SOL.3.91.1001222011507.22964B-100000@cse.cygnus.com>
On Dec 22, 2000, Benjamin Kosnik <bkoz@redhat.com> wrote:
>> IRIX 5.2's stdlib.h defines mblen as a macro. I wonder whether we
>> should just #ifdef the declaration out in this case, or define
>> std::(mblen) as an inline function that expands the macro, or do as
>> the patch below (mblen is available as a function, despite the
>> existence of the macro).
> Hmm. Not ok to install. Of the options you presented, making an inline
> function that expands the macro and then undefs the define is preferred.
Indeed. Here's a revised patch. Ok to install?
> if mblen is available as a function and as a macro, and which is
> used depends on a macro, then toggle that macro in
> config/os/irix/bits/os_defines.h so that you only get the function,
> and not the macro.
Unfortunately, that's not the case. The macro is defined whenever the
function is declared. Or so it seems to me.
Index: libstdc++-v3/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* include/c_std/bits/std_cstdlib.h (mblen): Expand macro to
inline function.
Index: libstdc++-v3/include/c_std/bits/std_cstdlib.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/c_std/bits/std_cstdlib.h,v
retrieving revision 1.4
diff -u -p -r1.4 std_cstdlib.h
--- libstdc++-v3/include/c_std/bits/std_cstdlib.h 2000/12/22 00:27:01 1.4
+++ libstdc++-v3/include/c_std/bits/std_cstdlib.h 2000/12/25 21:09:39
@@ -85,7 +85,12 @@ namespace std
extern "C" long int labs(long int);
extern "C" div_t div(int, int);
extern "C" ldiv_t ldiv(long int, long int);
+#ifdef mblen
+ inline int (mblen)(const char *p, size_t l) { return mblen(p, l); }
+#undef mblen
+#else
extern "C" int mblen(const char*, size_t);
+#endif
extern "C" int mbtowc(wchar_t*, const char*, size_t);
extern "C" int wctomb(char*, wchar_t);
extern "C" size_t mbstowcs(wchar_t*, const char*, size_t);
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me