C++/C mangleof inconsistency for OS X

Dan Olson via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 20 09:33:08 PDT 2015


An observation on OSX w/ 2.067: mangleof for C++ (and D) names produces
the actual object file symbol while mangleof for C names strips a
leading underscore.

Is this intended?  If so what is rationale?

Demo

$ cat >showmangle.d <<XYZZY
void dfun(int);
extern(C++) void cxxfun(int);
extern (C) void cfun(int);

pragma(msg, dfun.mangleof);
pragma(msg, cxxfun.mangleof);
pragma(msg, cfun.mangleof);

void main()
{
    dfun(1);
    cxxfun(1);
    cfun(1);
}
XYZZY

$ dmd -c showmangle.d 
_D10showmangle4dfunFiZv
__Z6cxxfuni
cfun

$ nm showmangle.o | grep fun
                 U _D10showmangle4dfunFiZv
                 U __Z6cxxfuni
                 U _cfun

--
Dan


More information about the Digitalmars-d mailing list