|
SDL3pp
A slim C++ wrapper for SDL3
|
System-dependent library loading routines. More...
Classes | |
| struct | SDL::SharedObject |
| An opaque datatype that represents a loaded shared object. More... | |
Typedefs | |
| using | SDL::SharedObjectRaw = SDL_SharedObject* |
| Alias to raw representation for SharedObject. | |
| using | SDL::SharedObjectRef = ResourceRef<SharedObject> |
| Reference for SharedObject. | |
Functions | |
| SharedObject | SDL::LoadObject (StringParam sofile) |
| Dynamically load a shared object. | |
| FunctionPointer | SDL::LoadFunction (SharedObjectRef handle, StringParam name) |
| Look up the address of the named function in a shared object. | |
| void | SDL::UnloadObject (SharedObjectRaw handle) |
| Unload a shared object from memory. | |
| SDL::SharedObject::SharedObject (StringParam sofile) | |
| Dynamically load a shared object. | |
| FunctionPointer | SDL::SharedObject::LoadFunction (StringParam name) |
| Look up the address of the named function in a shared object. | |
| void | SDL::SharedObject::Unload () |
| Unload a shared object from memory. | |
System-dependent library loading routines.
Shared objects are code that is programmatically loadable at runtime. Windows calls these "DLLs", Linux calls them "shared libraries", etc.
To use them, build such a library, then call LoadObject() on it. Once loaded, you can use SharedObject.LoadFunction() on that object to find the address of its exported symbols. When done with the object, call SharedObject.Unload() to dispose of it.
Some things to keep in mind:
| using SDL::SharedObjectRef = ResourceRef<SharedObject> |
Reference for SharedObject.
This does not take ownership!
|
inline |
Look up the address of the named function in a shared object.
This function pointer is no longer valid after calling SharedObject.Unload().
This function can only look up C function names. Other languages may have name mangling and intrinsic language support that varies from compiler to compiler.
Make sure you declare your function pointers with the same calling convention as the actual library function. Your code will crash mysteriously if you do not do this.
If the requested function doesn't exist, nullptr is returned.
| handle | a valid shared object handle returned by LoadObject(). |
| name | the name of the function to look up. |
|
inline |
Look up the address of the named function in a shared object.
This function pointer is no longer valid after calling SharedObject.Unload().
This function can only look up C function names. Other languages may have name mangling and intrinsic language support that varies from compiler to compiler.
Make sure you declare your function pointers with the same calling convention as the actual library function. Your code will crash mysteriously if you do not do this.
If the requested function doesn't exist, nullptr is returned.
| name | the name of the function to look up. |
|
inline |
Dynamically load a shared object.
| sofile | a system-dependent name of the object file. |
|
inline |
Dynamically load a shared object.
| sofile | a system-dependent name of the object file. |
|
inline |
Unload a shared object from memory.
Note that any pointers from this object looked up through SharedObject.LoadFunction() will no longer be valid.
|
inline |
Unload a shared object from memory.
Note that any pointers from this object looked up through SharedObject.LoadFunction() will no longer be valid.
| handle | a valid shared object handle returned by LoadObject(). |