SDL_loadso.h 3.8 KB

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