for example:use vc compile on x86
func.c:
__declspec(dllexport) int _stdcall sub(int a,int b)
{
        return a-b;
}

func.def:

LIBRARY
EXPORTS
sub

-----------------
i use "implib.exe" to create a omf format lib.
----------------
D code:
import std.exception;

//this is a cdecl call
extern(C) int sub(int a,int b);

void main()
{
    auto c1 = sub(2,1);

    //when this line run,the c1 value is broken
    auto c2 = enforceEx!Exception(sub(1,2));
}
------------------
my question is how write D code to call the c function

Reply via email to