G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsExport.h
Go to the documentation of this file.
1
14#pragma once
15
16#include <gsCore/gsConfig.h>
17
18
19/*
20 Symbol exporting and importing
21
22 By default no symbols are exported to the shared library. Symbols
23 that have to be exported must be marked with GISMO_EXPORT. Symbols
24 that should not be exported can be marked with GISMO_LOCAL.
25 Also:
26
27 - When building the shared library, gismo_EXPORTS must be defined,
28 but NOT when consuming G+Smo as a shared library
29
30 - When building the static library, gismo_STATIC must be defined
31
32 - If GISMO_BUILD_LIB is defined when building or consuming the
33 shared or static library then function definitions in .hpp files are
34 not included after class/function declarations. Otherwise
35 (GISMO_BUILD_LIB not defined) a pure template build will take place.
36 The macro GISMO_BUILD_LIB is controlled in gsCore/gsConfig.h.
37
38 info: https://gcc.gnu.org/wiki/Visibility
39*/
40#if defined(gismo_STATIC) // using/building static library
41
42# define GISMO_EXPORT
43# define GISMO_IMPORT
44//# define GISMO_LOCAL
45# define GISMO_DEFAULT_VIS //GCC warns when base/derived class differ in visibility, this macro allows to add attribute to the templated base
46
47#elif defined(gismo_EXPORTS) // building shared library: export, don't import
48
49# if defined(_WIN32) || defined(__CYGWIN__)
50# define GISMO_EXPORT __declspec(dllexport) //equiv. __attribute__ ((dllexport))
51//# define GISMO_LOCAL
52# define GISMO_DEFAULT_VIS
53# else
54# define GISMO_EXPORT __attribute__((visibility("default")))
55//# define GISMO_LOCAL __attribute__((visibility("hidden" )))
56# define GISMO_DEFAULT_VIS __attribute__((visibility("default")))
57# endif
58# define GISMO_IMPORT
59
60#else // using shared library: import all
61
62# if defined(_WIN32) || defined(__CYGWIN__)
63# define GISMO_EXPORT __declspec(dllimport) //equiv. __attribute__ ((dllimport))
64# define GISMO_IMPORT __declspec(dllimport)
65# else
66// GCC: If a symbol declared dllimport is later defined, the attribute
67// is ignored in subsequent references, and a warning is emitted.
68# define GISMO_EXPORT //__attribute__ ((dllimport))
69# define GISMO_IMPORT //__attribute__ ((dllimport))
70# endif
71//# define GISMO_LOCAL
72# define GISMO_DEFAULT_VIS
73#endif
74
75
76/*
77 Macros for instantiating templated structs, classes or functions.
78
79 - When using the shared library all instantiations are expected to
80 be imported from the library are marked as "extern template". This
81 allows the compile to avoid to instantiate the template in this
82 translation unit.
83
84 - When compiling the translation unit for an explicit template
85 instantiation of a certain templated class, the
86 EXTERN_CLASS_TEMPLATE must be replaced with an explicit
87 instantiation directive, i.e. CLASS_TEMPLATE_INST.
88
89 - On GCC the scheme would work if the "extern template" where still
90 present in the headers and CLASS_TEMPLATE_INST would follow later.
91 Hoever, in MSVC2010, "extern template" cannot be followed later by
92 an explicit instantization. Actually MSVC considers "extern
93 template" already to be an instantization, which can happen only
94 once in the translation unit. Hence the error C2960 is emitted.
95
96 - The compiler is free to inline any function that it has the
97 definition for, if it chooses to do so.
98
99 info: https://support.microsoft.com/en-us/kb/168958
100*/
101#define STRUCT_TEMPLATE_INST template struct GISMO_EXPORT
102#define CLASS_TEMPLATE_INST template class GISMO_EXPORT
103#define TEMPLATE_INST template GISMO_EXPORT
104#define EXTERN_STRUCT_TEMPLATE extern template struct GISMO_IMPORT
105#define EXTERN_CLASS_TEMPLATE extern template class GISMO_IMPORT
106#define EXTERN_TEMPLATE extern template GISMO_IMPORT
107
108#ifndef __has_feature // clang only
109#define __has_feature(x) 0
110#endif
111
112/*
113 Override control
114
115 - GISMO_FINAL
116 Marks a virtual method indicating that derived classes cannot
117 override it, or mark a class to indicate that there can be no
118 derived classes.
119
120 Example:
121 virtual void foo() GISMO_FINAL;
122 class B GISMO_FINAL : public A {};
123
124 - GISMO_OVERRIDE
125 Marks a virtual method indicating it must be overriding a virtual
126 method of the base class
127
128 Example:
129 virtual void foo() GISMO_OVERRIDE;
130*/
131#if defined(_MSC_VER) && _MSC_VER < 1700 // all versions before MSVC 2012
132// MSVC2010 uses "sealed", later versions accept final as well
133# define GISMO_FINAL sealed
134# define GISMO_OVERRIDE override
135#elif _MSC_VER >= 1700 // MSVC 2012 upward
136# define GISMO_FINAL final
137# define GISMO_OVERRIDE override
138#elif defined(__clang__ ) && __has_feature(cxx_override_control)
139# define GISMO_FINAL final
140# define GISMO_OVERRIDE override
141#elif defined(__GNUG__) && __cplusplus >= 201103 && \
142 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
143// GCC 4.7 supports override control with C++11 enabled
144# define GISMO_FINAL final
145# define GISMO_OVERRIDE override
146#else
147# define GISMO_FINAL
148# define GISMO_OVERRIDE
149#endif
Provides preprocessor directives configuration of G+Smo.