alias and extern(C) for callbacks
Carl Sturtivant
sturtivant at gmail.com
Thu Aug 22 17:14:55 PDT 2013
On Friday, 23 August 2013 at 00:00:13 UTC, Andrej Mitrovic wrote:
> On Thursday, 22 August 2013 at 23:55:44 UTC, Carl Sturtivant
> wrote:
>> Is Callback here a name for the same type as if it was defined
>> by the following?
>>
>> alias extern(C) int function(int, int) Callback;
>
> Yes. If you want to make sure, you can use a trait:
>
> import std.traits;
>
> extern(C) { void test1() { } }
> void test2() { }
>
> static assert(functionLinkage!test1 == "C");
> static assert(functionLinkage!test2 != "C"); // D calling
> convention
Nice! Thank you.
More information about the Digitalmars-d-learn
mailing list