extern(C) names are being mangled; that's crazy, Walter says I'm crazy

Manu turkeyman at gmail.com
Wed Jul 24 21:24:42 UTC 2019


On Wed, Jul 24, 2019 at 6:55 AM Adam D. Ruppe via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On Wednesday, 24 July 2019 at 05:03:16 UTC, Manu wrote:
> > I can't believe the idea that extern(C) functions being mangled
> > to un-knowable generated names is what any sane user would ever
> > expect.
>
> I have used this pattern for callbacks before without even
> thinking about it, and it just worked. I have also hit some
> annoyance like you saw (and before pragma(mangle) it was really
> annoying, now it is just "huh i forgot to do that").

In that callback case, they're effectively anonymously named
functions... The name is irrelevant, and so is the mangling. So that
is the case where pragma(mangle, "IDontCare") should be used. There
shouldn't be edge cases and surprises where extern(C) means something
sometimes, and something else in this weird edge case.

> I wonder if you have ever done a callback use case too and never
> even noticed it exactly because it just works, but then pay a lot
> of attention to this because it doesn't.

I have not. I would *never* expect to declare multiple extern(C)
functions with the same name from the same file and not have link
errors. Nobody would expect that. Mangling extern(C) functions is
ABSOLUTELY NOT extern(C).
If I didn't get the link error I was expecting, I would be angry, and
emitting the exact same rant.
extern(C) shouldn't mean different shit in different cases. I can't
believe anyone thinks that's okay.


More information about the Digitalmars-d mailing list