Posted 02 July 2009 - 03:05 AM
Am I missing something? The only solution I know about is remote function calling between executables via a network (Java has this).
Posted 02 July 2009 - 04:18 AM
As for linking to functions not known at compile time, you certainly can do this - as an example, in Windows, you can use GetProcAddress32 to look up a symbol by name. Of course, you have to know the type of the function to call it properly. Import libraries are, I believe, just a wrapper around this, with the actual module loading and lookup being done by the C runtime.
Posted 02 July 2009 - 05:09 AM
To clarify, I mean cross platform in the sense of a standard way of making and accessing an external library. As it stands for the c, there's .dll on windows, and .dylib and on mac and .so on unix.
I will read up on GetProcAddress, it looks promising. Perhaps there is a mac equivalent. Thanks for the ideas,
Posted 02 July 2009 - 06:42 AM
Yes it's a pain for someone who writes his own compiler, but there's no way around it. Fortunately though, once you've got it working on one platform the others are very similar.
Anyway, exactly how does your language work? Do you translate it to C and then compile it with an existing compiler? Or do you compile it to assembly code and use an assembler to create the binary code? Or do you generate the binary code yourself? And in what environment is the code used? A standalone executable, a dynamically loaded framework, a network service?
We'll be able to help you better if you could give us more details about your actual goals.
Posted 02 July 2009 - 03:10 PM
I'm attempting to create a (at least partial) implementation of the Io language( for my own learning, and perhaps to produce a faster implementation).
Basically, the plan is to read in a Io program (as text), convert it into a message-pass tree, and then execute that tree. I'm using plain c, and have defined some very generic structures for objects, messages, methods, etc. To avoid needing to know function types at compile time, all underlying c-functions have exactly 2 parameters(an int for the number of parameters, and a pointer to an array of parameters) and return a generic struct. I've written most of a message passing function that transverses a message tree, looks up slots, and then calls appropriate method(some of which call underlying c-functions to get things done). The issue I see is that although my executable will have built in basic functions, Io does allow external c-functions to be called. For example, someone should be able to write a method in Io that binds to an openGL function.
This is my first attempt at something like this and also the first time I've explored dynamic linking.
Posted 02 July 2009 - 04:34 PM
Posted 02 July 2009 - 05:08 PM
If it is a C++ library, you should be able to write a wrapper using extern "C" directives.
A more useful link is at https://developer.mozilla.org/en/NSPR if you're interested.
Posted 02 July 2009 - 10:11 PM
Currently working on: the 3D engine for Tomb Raider.
Posted 02 July 2009 - 11:37 PM
Posted 03 July 2009 - 01:32 AM
Posted 03 July 2009 - 11:56 PM
You're welcome! I think there may be a simpler wrapper for shared libraries in SDL 1.2.13 also if NSPR proves to be too bulky.
One reason that a central API would be desirable for such things would be to make a source-code relatively future-proof. If you wanted to support more than the 3 standard OSs that everybody supports, for example.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users