how to declare C's static function?

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 27 21:33:06 PDT 2016


On Monday, 28 March 2016 at 04:27:27 UTC, aki wrote:
> On Monday, 28 March 2016 at 04:12:56 UTC, Rikki Cattermole 
> wrote:
>> Do you need it to use extern(C)?
>> Because if you don't, just drop that. D's mangling will fix it.
>
> Yes, I do need extern(C) for some reason like:
> alias Hook = extern(C) void function();
> void sethook(Hook func) {
>     ...
> }
> ... sethook(&foo) ...
>
> Some function expects such a function as an argument.
>
> Aki.

Okay so you're needing extern(C).
I was assuming they were just internal functions.

You have two choices. Change the name in code (so manual 
mangling) or use pragma(mangle, ...) to change it instead.


More information about the Digitalmars-d-learn mailing list