This is the mail archive of the libstdc++@gcc.gnu.org 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 31, 2000, Gabriel Dos Reis <gdr@codesourcery.com> wrote:

> Fair enough.  *You* are the person who first made the assumption, 
> in http://gcc.gnu.org/ml/gcc-patches/2000-12/msg01333.html, that
> an implementation might just the function only as a macro:

That's because I was under the impression you had mis-understood the
problem, and was suggesting a more complicated implementation because
you thought the function was missing.  Looks like my impression was
correct :-)

> As for your patch, std::mblen should name the same entity as ::mblen,
> in addition of #undefing mblen.

I still fail to understand why they should be the same entity.  We'd
lose the optimization opportunity that the header files of the system
attempt to offer, and failing to work in case the name is only
available as a macro (which is not the case at hand, but it might be
on other systems).  These two problems are absent with the
implementation in my latest patch, as proposed by Ben.  

But, if you have a good argument against the patch I last proposed,
here's one that does it as you suggest.  Ok to install?

Index: libstdc++-v3/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* include/c_std/bits/std_cstdlib.h (mblen): Protect against macro.

Index: libstdc++-v3/include/c_std/bits/std_cstdlib.h
--- libstdc++-v3/include/c_std/bits/std_cstdlib.h
+++ libstdc++-v3/include/c_std/bits/std_cstdlib.h
@@ -85,6 +85,9 @@ 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
+#undef mblen
+#endif
   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); 


-- 
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

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