alias and extern(C) for callbacks

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Aug 22 17:00:09 PDT 2013


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


More information about the Digitalmars-d-learn mailing list