Prevent macro expansion of mblen

Gabriel Dos Reis gdr@codesourcery.com
Thu Dec 28 12:40:00 GMT 2000


Alexandre Oliva <aoliva@redhat.com> writes:

| On Dec 28, 2000, Gabriel Dos Reis <gdr@codesourcery.com> wrote:
| 
| > | +#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
| 
| > "mblen" needs to have C linkage in all cases.
| 
| Is it std::mblen that must have C linkage?  I ask because ::mblen
| is declared and defined in the C library, and it does have C linkage.

We want all C-functions, whether there are shadowed (i.e. brought in
scope through <cxxx> or <xxx.h> headers) have C linkage  -- this
ensures that those names ultimately refer to the same entities --
without exceptions for the reasons I exposed in another message.

| Isn't this inline function enough?

No.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com


More information about the Libstdc++ mailing list