newLISP.dll with cdecl-option?

Started by HPW, September 17, 2004, 12:55:22 AM

Previous topic - Next topic

HPW

Amazed from the ongoing process of using newLISP in other enviroments come this next option to my mind:



Is it possible to get a optional makefile for compiling newLISP.dll with cdecl-calling convention so that 'newlispEvalStr' can be directly called from C-programs?



Background: Existing apps written in C often offers plugin interfaces with cdecl-calling convention. So it would be nice to use newLISP.dll there without any wrapper DLL's.



Since newLISP allow 'cdecl-calling' on import it would be nice when we could do it on export.
Hans-Peter

Lutz

#1
Why shoudn't it be possible to call newlisp.dll from 'C' programs right now?



#ifdef STDCALL
int _stdcall (*function)();
#else /* cdecl */
int (*function)();
#endif

if((hLibrary = LoadLibrary(libName)) < 32)
        printf("cannot import library");

if((function = GetProcAddress(hLibrary, (LPCSTR)funcName)) == NULL)
printf("don't know this function");

/* call the function */

result = (*function)();



The code shows you how to import either way on Win32. When importing into 'C' the difference is only, how you declare the function. newLISP can import newlisp.dll this way.



Lutz

HPW

#2
I have not think enough before posting.



Having a C-app without source, I can not call newLISP because it does not know about the exported function 'newlispEvalStr'.

Having a C-app with source, I can modify that it does the right call.



So forget this post.
Hans-Peter