registering C functions to Newlisp

Pondering the philosophy behind the language

registering C functions to Newlisp

Postby Astrobe » Tue Jan 15, 2013 10:19 pm

I'd like to use Newlisp on system that runs uClinux, which does not support shared libraries. I also would like to use some C++ libraries.

My first idea was to hack a bit Newlisp so that one could relatively easily add "foreign" functions to the list of primitives functions. But another difficulty is to link C and C++ together. The best way is to compile the C files (newlisp) with C++ (my libraries), but compiling newlisp as C++ fails (it might be possible, but I also have to use a quite old version of gcc).

Another idea is to use the newlisp-as-library way: compile a small main() and my libraries with G++, then link the newlisp static library to it. The extra step to make it work is to be able to register, with a C function provided by the newlisp library, another C function (which would in my case just be an interface for calling C++ stuff). I took a look at nl-import.c and the code that imports C functions from shared libraries and it seems to me it's possible to do that.

I'm not yet familiar with newlisp's internal and I'd like to hear your opinion on how easy or hard it would be to do that before diving in.
Posts: 39
Joined: Mon Jan 11, 2010 9:41 pm

Return to Whither newLISP?

Who is online

Users browsing this forum: No registered users and 1 guest