Callbacks and interfacing with C

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Oct 30 10:44:08 PDT 2012


On 10/30/12, Nick Sabalausky <SeeWebsiteToContactMe at semitwist.com> wrote:
> Which, if any, of foo1/foo2/foo3 are extern(C)? (I know bar definitely
> is.)

All of them.

void main()
{
    pragma(msg, MyFn);
    pragma(msg, typeof(MyStruct.foo2));
    pragma(msg, typeof(bar));
}

extern (C) int function(int)
extern (C) int function(int)
extern (C) void(extern (C) int function(int) foo3)
extern (C) int function(int)
extern (C) int function(int)
extern (C) void(extern (C) int function(int) foo3)

It's because extern(C): leaks everywhere, whether on purpose or not.
It can be a benefit for writing shorter code, but when reading such
code it's easy to forget to check for an extern(C): declaration at the
top and just wrongly assume that it's all extern(D).


More information about the Digitalmars-d-learn mailing list