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