newLISP.dll with cdecl-option?

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

newLISP.dll with cdecl-option?

Post by 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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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

Code: Select all

#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
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

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

Locked