SDL 2.0
SDL_loadso.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22/* WIKI CATEGORY: LoadSO */
23
24/**
25 * # CategoryLoadSO
26 *
27 * System-dependent library loading routines.
28 *
29 * Some things to keep in mind:
30 *
31 * - These functions only work on C function names. Other languages may have
32 * name mangling and intrinsic language support that varies from compiler to
33 * compiler.
34 * - Make sure you declare your function pointers with the same calling
35 * convention as the actual library function. Your code will crash
36 * mysteriously if you do not do this.
37 * - Avoid namespace collisions. If you load a symbol from the library, it is
38 * not defined whether or not it goes into the global symbol namespace for
39 * the application. If it does and it conflicts with symbols in your code or
40 * other shared libraries, you will not get the results you expect. :)
41 */
42
43#ifndef SDL_loadso_h_
44#define SDL_loadso_h_
45
46#include "SDL_stdinc.h"
47#include "SDL_error.h"
48
49#include "begin_code.h"
50/* Set up for C function definitions, even when using C++ */
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55/**
56 * Dynamically load a shared object.
57 *
58 * \param sofile a system-dependent name of the object file.
59 * \returns an opaque pointer to the object handle or NULL if there was an
60 * error; call SDL_GetError() for more information.
61 *
62 * \since This function is available since SDL 2.0.0.
63 *
64 * \sa SDL_LoadFunction
65 * \sa SDL_UnloadObject
66 */
67extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
68
69/**
70 * Look up the address of the named function in a shared object.
71 *
72 * This function pointer is no longer valid after calling SDL_UnloadObject().
73 *
74 * This function can only look up C function names. Other languages may have
75 * name mangling and intrinsic language support that varies from compiler to
76 * compiler.
77 *
78 * Make sure you declare your function pointers with the same calling
79 * convention as the actual library function. Your code will crash
80 * mysteriously if you do not do this.
81 *
82 * If the requested function doesn't exist, NULL is returned.
83 *
84 * \param handle a valid shared object handle returned by SDL_LoadObject().
85 * \param name the name of the function to look up.
86 * \returns a pointer to the function or NULL if there was an error; call
87 * SDL_GetError() for more information.
88 *
89 * \since This function is available since SDL 2.0.0.
90 *
91 * \sa SDL_LoadObject
92 * \sa SDL_UnloadObject
93 */
94extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
95 const char *name);
96
97/**
98 * Unload a shared object from memory.
99 *
100 * \param handle a valid shared object handle returned by SDL_LoadObject().
101 *
102 * \since This function is available since SDL 2.0.0.
103 *
104 * \sa SDL_LoadFunction
105 * \sa SDL_LoadObject
106 */
107extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
108
109/* Ends C function definitions when using C++ */
110#ifdef __cplusplus
111}
112#endif
113#include "close_code.h"
114
115#endif /* SDL_loadso_h_ */
116
117/* vi: set ts=4 sw=4 expandtab: */
void * SDL_LoadObject(const char *sofile)
void * SDL_LoadFunction(void *handle, const char *name)
void SDL_UnloadObject(void *handle)