I got here in test.cpp this
Code: Select all
extern "C"
{
__declspec(dllexport) double adder(double a,double b) {
return (a+b);
}
}
Code: Select all
C:\Users\stefan\ffi>cl /LD /DLL test.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
test.cpp
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.dll
/dll
/implib:test.lib
test.obj
Creating library test.lib and object test.exp
But, when I start newlisp, import the func and start it, i get this:
Code: Select all
newLISP v.10.3.5 on Win32 IPv4/6 UTF-8, execute 'newlisp -h' for more info.
> (import "test.dll" "adder")
adder<10001000>
> (adder 2.2 3.0)
-1717986918
I wrote a test prog to see if the dll is ok:
Code: Select all
#include <stdio.h>
double adder(double a,double b);
int main(void) {
printf("%f\n",adder(3.2,4.5));
return 0;
}
Code: Select all
C:\Users\stefan\ffi>cl testtest.c test.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
testtest.c
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:testtest.exe
testtest.obj
test.lib
C:\Users\stefan\ffi>testtest.exe
7.700000
Where is my error ?