newLISP Fan Club

Forum => newLISP and the O.S. => Topic started by: HPW on September 17, 2004, 12:55:22 AM

Title: newLISP.dll with cdecl-option?
Post by: HPW on September 17, 2004, 12:55:22 AM
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.
Title:
Post by: Lutz on September 17, 2004, 05:12:49 AM
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
Title:
Post by: HPW on September 17, 2004, 06:44:59 AM
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.