ImathExport.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Copyright Contributors to the OpenEXR Project.
  4. //
  5. #ifndef INCLUDED_IMATHEXPORT_H
  6. #define INCLUDED_IMATHEXPORT_H
  7. #include "ImathConfig.h"
  8. /// \defgroup ExportMacros Macros to manage symbol visibility
  9. ///
  10. /// There is more information about the motivation for these macros
  11. /// documented in the OpenEXR source tree
  12. /// (https://github.com/AcademySoftwareFoundation/openexr) under
  13. /// docs/SymbolVisibility.md
  14. ///
  15. /// Imath only needs a couple of the possible macros outlined in the
  16. /// above document, and due to it largely being inline only, does not
  17. /// have much to do.
  18. ///
  19. /// @{
  20. #if defined(IMATH_DLL)
  21. // when building Imath as a DLL for Windows, we have to control the
  22. // typical DLL export / import things. Luckily, the typeinfo is all
  23. // automatic there, so only have to deal with symbols, except Windows
  24. // has some weirdness with DLLs and extern const, so we have to
  25. // provide a macro to handle that.
  26. # if defined(IMATH_EXPORTS)
  27. # define IMATH_EXPORT __declspec(dllexport)
  28. # define IMATH_EXPORT_CONST extern __declspec(dllexport)
  29. # else
  30. # define IMATH_EXPORT __declspec(dllimport)
  31. # define IMATH_EXPORT_CONST extern __declspec(dllimport)
  32. # endif
  33. // DLLs don't support these types of visibility controls, just leave them as empty
  34. # define IMATH_EXPORT_TYPE
  35. # define IMATH_EXPORT_ENUM
  36. # define IMATH_EXPORT_TEMPLATE_TYPE
  37. #else
  38. # ifdef IMATH_PUBLIC_SYMBOL_ATTRIBUTE
  39. # define IMATH_EXPORT IMATH_PUBLIC_SYMBOL_ATTRIBUTE
  40. # define IMATH_EXPORT_CONST extern const IMATH_PUBLIC_SYMBOL_ATTRIBUTE
  41. # else
  42. # define IMATH_EXPORT
  43. # define IMATH_EXPORT_CONST extern const
  44. # endif
  45. # ifdef IMATH_PUBLIC_TYPE_VISIBILITY_ATTRIBUTE
  46. # define IMATH_EXPORT_ENUM IMATH_PUBLIC_TYPE_VISIBILITY_ATTRIBUTE
  47. # define IMATH_EXPORT_TEMPLATE_TYPE IMATH_PUBLIC_TYPE_VISIBILITY_ATTRIBUTE
  48. # define IMATH_EXPORT_TYPE IMATH_PUBLIC_TYPE_VISIBILITY_ATTRIBUTE
  49. # else
  50. # define IMATH_EXPORT_ENUM
  51. # define IMATH_EXPORT_TEMPLATE_TYPE IMATH_EXPORT
  52. # define IMATH_EXPORT_TYPE IMATH_EXPORT
  53. # endif
  54. #endif // IMATH_DLL
  55. /// @}
  56. #endif // INCLUDED_IMATHEXPORT_H