SDL_loadso.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2021 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. /**
  19. * \file SDL_loadso.h
  20. *
  21. * System dependent library loading routines
  22. *
  23. * Some things to keep in mind:
  24. * \li These functions only work on C function names. Other languages may
  25. * have name mangling and intrinsic language support that varies from
  26. * compiler to compiler.
  27. * \li Make sure you declare your function pointers with the same calling
  28. * convention as the actual library function. Your code will crash
  29. * mysteriously if you do not do this.
  30. * \li Avoid namespace collisions. If you load a symbol from the library,
  31. * it is not defined whether or not it goes into the global symbol
  32. * namespace for the application. If it does and it conflicts with
  33. * symbols in your code or other shared libraries, you will not get
  34. * the results you expect. :)
  35. */
  36. #ifndef SDL_loadso_h_
  37. #define SDL_loadso_h_
  38. #include "SDL_stdinc.h"
  39. #include "SDL_error.h"
  40. #include "begin_code.h"
  41. /* Set up for C function definitions, even when using C++ */
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /**
  46. * Dynamically load a shared object.
  47. *
  48. * \param sofile a system-dependent name of the object file
  49. * \returns an opaque pointer to the object handle or NULL if there was an
  50. * error; call SDL_GetError() for more information.
  51. *
  52. * \sa SDL_LoadFunction
  53. * \sa SDL_UnloadObject
  54. */
  55. extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
  56. /**
  57. * Look up the address of the named function in a shared object.
  58. *
  59. * This function pointer is no longer valid after calling SDL_UnloadObject().
  60. *
  61. * This function can only look up C function names. Other languages may have
  62. * name mangling and intrinsic language support that varies from compiler to
  63. * compiler.
  64. *
  65. * Make sure you declare your function pointers with the same calling
  66. * convention as the actual library function. Your code will crash
  67. * mysteriously if you do not do this.
  68. *
  69. * If the requested function doesn't exist, NULL is returned.
  70. *
  71. * \param handle a valid shared object handle returned by SDL_LoadObject()
  72. * \param name the name of the function to look up
  73. * \returns a pointer to the function or NULL if there was an error; call
  74. * SDL_GetError() for more information.
  75. *
  76. * \sa SDL_LoadObject
  77. * \sa SDL_UnloadObject
  78. */
  79. extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
  80. const char *name);
  81. /**
  82. * Unload a shared object from memory.
  83. *
  84. * \param handle a valid shared object handle returned by SDL_LoadObject()
  85. *
  86. * \sa SDL_LoadFunction
  87. * \sa SDL_LoadObject
  88. */
  89. extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle);
  90. /* Ends C function definitions when using C++ */
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #include "close_code.h"
  95. #endif /* SDL_loadso_h_ */
  96. /* vi: set ts=4 sw=4 expandtab: */