This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Prevent macro expansion of mblen

On Dec 22, 2000, Benjamin Kosnik <> 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  <>

	* 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
   extern "C" int mblen(const char*, size_t); 
   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
Red Hat GCC Developer                  aoliva@{,}
CS PhD student at IC-Unicamp        oliva@{,}
Free Software Evangelist    *Please* write to mailing lists, not to me

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]