icedb  version 0.5.1
Snow particle scattering database API
defs.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef ICEDB_H_DEFS
3 #define ICEDB_H_DEFS
4 #define __STDC_WANT_LIB_EXT1__ 1
5 #include <stddef.h>
6 
7 #if defined(__cplusplus) || defined(c_plusplus)
8 # define ICEDB_BEGIN_DECL
9 # define ICEDB_END_DECL
10 #else
11 # define ICEDB_BEGIN_DECL
12 # define ICEDB_END_DECL
13 #endif
14 
15 #if defined(__cplusplus) || defined(c_plusplus)
16 # define ICEDB_BEGIN_DECL_C extern "C" {
17 # define ICEDB_END_DECL_C }
18 # define ICEDB_CALL_C extern "C"
19 #else
20 # define ICEDB_BEGIN_DECL_C
21 # define ICEDB_END_DECL_C
22 # define ICEDB_CALL_C
23 #endif
24 
25 #if defined(__cplusplus) || defined(c_plusplus)
26 # define ICEDB_BEGIN_DECL_CPP
27 # define ICEDB_END_DECL_CPP
28 # define ICEDB_CALL_CPP
29 #else
30 # define ICEDB_BEGIN_DECL_CPP extern "CPP" {
31 # define ICEDB_END_DECL_CPP }
32 # define ICEDB_CALL_CPP extern "CPP"
33 #endif
34 
35 // gcc 4.4 will not work. No decltype!
36 // constexpr fix for gcc 4.4
37 //#if defined(__cplusplus)
38 //#if __cplusplus < 201103L
39 //#define constexpr const
40 //#define noexcept
41 //#endif
42 //#endif
43 
45 
46 /* Compiler and version diagnostics */
47 
48 /* Detection of the operating system and compiler version. Used to declare symbol export / import. */
49 
50 /* Declare the feature sets that are supported */
51 //#define ICEDB_FEATURE_GZIP 0 /* Auto-detection of gzip. Needed for hdf5 file storage. */
52 
53 
54 /* Symbol export / import macros */
55 #if defined _MSC_FULL_VER
56 #define COMPILER_EXPORTS_VERSION_A_ICEDB
57 #elif defined __INTEL_COMPILER
58 #define COMPILER_EXPORTS_VERSION_B_ICEDB
59 #elif defined __GNUC__
60 #define COMPILER_EXPORTS_VERSION_B_ICEDB
61 #elif defined __MINGW32__
62 #define COMPILER_EXPORTS_VERSION_B_ICEDB
63 #elif defined __clang__
64 #define COMPILER_EXPORTS_VERSION_B_ICEDB
65 #else
66 #define COMPILER_EXPORTS_VERSION_UNKNOWN
67 #endif
68 
69 // Defaults for static libraries
70 #define SHARED_EXPORT_ICEDB
71 #define SHARED_IMPORT_ICEDB
72 #define HIDDEN_ICEDB
73 #define PRIVATE_ICEDB
74 
75 #if defined COMPILER_EXPORTS_VERSION_A_ICEDB
76 #undef SHARED_EXPORT_ICEDB
77 #undef SHARED_IMPORT_ICEDB
78 #define SHARED_EXPORT_ICEDB __declspec(dllexport)
79 #define SHARED_IMPORT_ICEDB __declspec(dllimport)
80 #elif defined COMPILER_EXPORTS_VERSION_B_ICEDB
81 #undef SHARED_EXPORT_ICEDB
82 #undef SHARED_IMPORT_ICEDB
83 #undef HIDDEN_ICEDB
84 #undef PRIVATE_ICEDB
85 #define SHARED_EXPORT_ICEDB __attribute__ ((visibility("default")))
86 #define SHARED_IMPORT_ICEDB __attribute__ ((visibility("default")))
87 #define HIDDEN_ICEDB __attribute__ ((visibility("hidden")))
88 #define PRIVATE_ICEDB __attribute__ ((visibility("internal")))
89 #else
90 #pragma message("defs.h warning: compiler is unrecognized")
91 #endif
92 
93 // OS definitions
94 #ifdef __unix__
95 #ifdef __linux__
96 #define ICEDB_OS_LINUX
97 #endif
98 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || defined(__APPLE__)
99 #define ICEDB_OS_UNIX
100 #endif
101 #endif
102 #ifdef _WIN32
103 #define ICEDB_OS_WINDOWS
104 #endif
105 #if !defined(_WIN32) && !defined(ICEDB_OS_UNIX) && !defined(ICEDB_OS_LINUX)
106 #define ICEDB_OS_UNSUPPORTED
107 #endif
108 
109 
110 // If SHARED_(libname) is defined, then the target library both
111 // exprts and imports. If not defined, then it is a static library.
112 
113 // Macros defined as EXPORTING_(libname) are internal to the library.
114 // They indicate that SHARED_EXPORT_SDBR should be used.
115 // If EXPORTING_ is not defined, then SHARED_IMPORT_SDBR should be used.
116 
117 #if SHARED_libicedb
118 #if EXPORTING_libicedb
119 #define DL_ICEDB SHARED_EXPORT_ICEDB
120 #else
121 #define DL_ICEDB SHARED_IMPORT_ICEDB
122 #endif
123 #else
124 #define DL_ICEDB SHARED_EXPORT_ICEDB
125 #endif
126 /* Symbol export / import macros */
127 #define ICEDB_SYMBOL_SHARED DL_ICEDB
128 #define ICEDB_SYMBOL_PRIVATE HIDDEN_ICEDB
129 
130 
131 #ifdef _MSC_FULL_VER
132 #define ICEDB_DEBUG_FSIG __FUNCSIG__
133 #endif
134 #if defined(__GNUC__) || defined(__clang__)
135 #if defined(__PRETTY_FUNCTION__)
136 #define ICEDB_DEBUG_FSIG __PRETTY_FUNCTION__
137 #elif defined(__func__)
138 #define ICEDB_DEBUG_FSIG __func__
139 #elif defined(__FUNCTION__)
140 #define ICEDB_DEBUG_FSIG __FUNCTION__
141 #else
142 #define ICEDB_DEBUG_FSIG ""
143 #endif
144 #endif
145 
146 #define ICEDB_WIDEN2(x) L ## x
147 #define ICEDB_WIDEN(x) ICEDB_WIDEN2(x)
148 /* Global exception raising code (invokes debugger) */
149 ICEDB_SYMBOL_SHARED void ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER_A(const char*, int, const char*);
150 ICEDB_SYMBOL_SHARED void ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER_WC(const wchar_t*, int, const wchar_t*);
151 #define ICEDB_DEBUG_RAISE_EXCEPTION() ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER_WC( ICEDB_WIDEN(__FILE__), (int)__LINE__, ICEDB_WIDEN(ICEDB_DEBUG_FSIG));
152 
153 #define ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER_A
154 /* Global error codes. */
155 #define ICEDB_GLOBAL_ERROR_TODO 999
156 #if defined(__STDC_LIB_EXT1__) || defined(__STDC_SECURE_LIB__)
157 #define ICEDB_USING_SECURE_STRINGS 1
158 #define ICEDB_DEFS_COMPILER_HAS_FPRINTF_S
159 #define ICEDB_DEFS_COMPILER_HAS_FPUTS_S
160 #else
161 #define _CRT_SECURE_NO_WARNINGS
162 #endif
163 
164 /* Thread local storage stuff */
165 #ifdef _MSC_FULL_VER
166 #define ICEDB_THREAD_LOCAL __declspec( thread )
167 #endif
168 #ifdef __GNUC__
169 #define ICEDB_THREAD_LOCAL __thread
170 #endif
171 
172 // Compiler interface warning suppression
173 #if defined _MSC_FULL_VER
174 #pragma warning(push)
175 #pragma warning( disable : 4003 ) // Bug in boost with VS2016.3
176 #pragma warning( disable : 4251 ) // DLL interface
177 #pragma warning( disable : 4275 ) // DLL interface
178 #endif
179 
181 #define ICEDB_OUT
182 #define ICEDB_OPTIONAL
184 
186 
187 // Errata:
188 
189 #ifndef ICEDB_NO_ERRATA
190 // Boost bug with C++17 requires this define. See https://stackoverflow.com/questions/41972522/c2143-c2518-when-trying-to-compile-project-using-boost-multiprecision
191 #ifndef _HAS_AUTO_PTR_ETC
192 #define _HAS_AUTO_PTR_ETC (!_HAS_CXX17)
193 #endif /* _HAS_AUTO_PTR_ETC */
194 #endif
195 
196 #endif
#define ICEDB_BEGIN_DECL_C
Definition: defs.h:20
ICEDB_SYMBOL_SHARED void ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER_A(const char *, int, const char *)
Definition: util.cpp:113
#define ICEDB_END_DECL_C
Definition: defs.h:21
ICEDB_SYMBOL_SHARED void ICEDB_DEBUG_RAISE_EXCEPTION_HANDLER_WC(const wchar_t *, int, const wchar_t *)
Definition: util.cpp:102
#define ICEDB_SYMBOL_SHARED
Definition: defs.h:127