export extern (C) void Fun Error

Matt Peterson ricochet1k at gmail.com
Fri Apr 27 08:04:44 PDT 2012


On Friday, 27 April 2012 at 13:02:56 UTC, 拖狗散步 wrote:
> On Friday, 27 April 2012 at 01:21:56 UTC, Trass3r wrote:
>>> export c callback fun:
>>>
>>> alias void function(int id) ConnectedCallBack;
>>> alias void function(int id, void* data, int len) ReadCallBack;
>>
>> add extern(C) to be safe
>
>
> Thank, Trass3r! Finally correct, why have to export these two?

You specified the C calling convention with 
UnmanagedFunctionPointer(CallingConvention.Cdecl), and extern(C) 
means use the C calling convention. Otherwise they'll be 
expecting a function using the D calling convention, which is 
incompatible.


More information about the Digitalmars-d mailing list