SDL_LoadFunction() is somewhat misnamed, since it can be used to load
data symbols, too on any reasonable platform.
Yes, but you have to know exactly what you’re doing if you try this.
I believe you have to declare your data dllexport on Windows, for example,
If you’re crazy enough to export data … :]
and you’ll have a lovely time trying to support C++ symbols from different
compilers.
Which is good thing since they can and do use different
calling conventions … and that’s just i386.
Latest XP64 even uses different calling conventions
for C code than its previous incarnation … argg …
Anyhow my original comment was simply that:
fp = (void (*)())SDL_LoadFunction(handle, “ent_func”);
isn’t actually strictly ISO conformant and a good compiler would
actually reject the program. gcc 4.x is moving towards
stricter compliance. If there’s a need to cheat or hack
about here, I would seem useful if SDL did the cheating,
rather than the application programmer. I previously suggested
something like:
union SDL_pointer {
void *data;
void (*function)(void);
};
however it may be possible to do even better, knowing what
functions SDL itself is likely to use, one could provide
some extra convenience by adding variants for those function
types, so the user wouldn’t have to write any casts for
those cases. For example:
typedef void (*SDL_audio_h_cft_2)(struct SDL_AudioCVT *, Uint16)
I have a complete automatically generated list of every
callback function type used by SDL, on a 'per header file’
basis (rather than globally), these types are detected and
generated by my wrapper generator program. I guess I could
try to paste those types together and generate a suitable
union type, if there was any interest. The naming convention
is evident:
SDL_audio_h_cft_2
^
header file name ^^^^^ callback function type + sequence number
There aren’t so many of these for SDL … OpenGL is another
story though …
BTW: I need these things because my system uses C++ classes
as functions. They can still be used as callbacks, using
the client data pointer and a wrapper (but it messes up
the garbage collector at the moment, if the callbacks
run in a different pthread)On Tue, 2006-02-07 at 22:10 -0800, Sam Lantinga wrote:
–
John Skaller
Felix, successor to C++: http://felix.sf.net