ufe  1.0
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
CfgCompilerMacros.h
Go to the documentation of this file.
1 #line 1 "E:/jenkins/workspace/ufe-full-windows/ufe/gitmodules/peptide/config/CfgCompilerMacros.h"
2 //-
3 // =============================================================================
4 // Copyright 2018 Autodesk, Inc. All rights reserved.
5 //
6 // Use of this software is subject to the terms of the Autodesk license
7 // agreement provided at the time of installation or download, or which
8 // otherwise accompanies this software in either electronic or hard copy form.
9 // =============================================================================
10 //+
11 
14 
15 
16 #ifndef PEPTIDE_CFG_COMPILER_MACROS_H
17 #define PEPTIDE_CFG_COMPILER_MACROS_H
18 
19 
20 //==============================================================================
21 // PLATFORM DETECTION
22 //==============================================================================
23 
24 #if defined(_WIN32)
25 #define PEPTIDE_WINDOWS
26 #elif defined(__linux__)
27 #define PEPTIDE_LINUX
28 #elif defined(__APPLE__)
29 #define PEPTIDE_OSX
30 #else
31 #error "Unsupported platform..."
32 #endif
33 
34 
35 //==============================================================================
36 // COMPILER DETECTION
37 //==============================================================================
38 
39 #if defined(__clang__)
40 // Clang C++ emulates GCC and MSC, so it has to appear early.
41 #define PEPTIDE_IS_CLANG 1
42 #elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
43 // Intel emulates MSC, so it has to appear early.
44 #define PEPTIDE_IS_INTEL 1
45 #elif defined(__GNUC__)
46 // GNU C++.
47 #define PEPTIDE_IS_GCC 1
48 #elif defined(_MSC_VER)
49 // Microsoft visual studio
50 #define PEPTIDE_IS_MSC 1
51 #else
52 #error "Unknown compiler configuration..."
53 #endif
54 
55 
56 // Clang Compiler versions.
57 //
58 #ifdef PEPTIDE_IS_CLANG
59 
60 #ifdef __apple_build_version__
61 
62 // Apple versions of clang. Note the Apple version naming scheme is unrelated
63 // to the official LLVM ones. Thus, we made no attempt unify these versioning
64 // schemes.
65 
66 #if (__clang_major__ <= 6)
67 #define PEPTIDE_AT_MOST_APPLECLANG60 1
68 #endif
69 
70 #if (__clang_major__ <= 7)
71 #define PEPTIDE_AT_MOST_APPLECLANG70 1
72 #endif
73 
74 #else
75 
76 // Official releases of clang
77 #if (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ <= 6))
78 #define PEPTIDE_AT_MOST_CLANG36 1
79 #endif
80 
81 #if (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ <= 7))
82 #define PEPTIDE_AT_MOST_CLANG37 1
83 #endif
84 
85 #if (__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ <= 8))
86 #define PEPTIDE_AT_MOST_CLANG38 1
87 #endif
88 
89 #endif
90 
91 #endif
92 
93 
94 // GCC Compiler versions.
95 //
96 // Note: these macros are also used for the Intel compiler when it is
97 // trying to emulate a particular version of the gcc compiler.
98 #ifdef PEPTIDE_IS_GCC
99 
100 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 8))
101 #define PEPTIDE_AT_MOST_GCC48 1
102 #endif
103 
104 #endif
105 
106 
107 // MSC Compiler versions
108 #ifdef PEPTIDE_IS_MSC
109 
110 #if _MSC_VER <= 1700
111 #define PEPTIDE_AT_MOST_MSVC2012 1
112 #endif
113 
114 #if _MSC_VER <= 1800
115 #define PEPTIDE_AT_MOST_MSVC2013 1
116 #endif
117 
118 #if _MSC_VER <= 1900
119 #define PEPTIDE_AT_MOST_MSVC2015 1
120 #endif
121 
122 #endif
123 
124 
125 // Default values...
126 #ifndef PEPTIDE_IS_CLANG
127 #define PEPTIDE_IS_CLANG 0
128 #endif
129 
130 #ifndef PEPTIDE_IS_GCC
131 #define PEPTIDE_IS_GCC 0
132 #endif
133 
134 #ifndef PEPTIDE_IS_INTEL
135 #define PEPTIDE_IS_INTEL 0
136 #endif
137 
138 #ifndef PEPTIDE_IS_MSC
139 #define PEPTIDE_IS_MSC 0
140 #endif
141 
142 #ifndef PEPTIDE_AT_MOST_APPLECLANG60
143 #define PEPTIDE_AT_MOST_APPLECLANG60 0
144 #endif
145 
146 #ifndef PEPTIDE_AT_MOST_APPLECLANG70
147 #define PEPTIDE_AT_MOST_APPLECLANG70 0
148 #endif
149 
150 #ifndef PEPTIDE_AT_MOST_CLANG36
151 #define PEPTIDE_AT_MOST_CLANG36 0
152 #endif
153 
154 #ifndef PEPTIDE_AT_MOST_CLANG37
155 #define PEPTIDE_AT_MOST_CLANG37 0
156 #endif
157 
158 #ifndef PEPTIDE_AT_MOST_CLANG38
159 #define PEPTIDE_AT_MOST_CLANG38 0
160 #endif
161 
162 #ifndef PEPTIDE_AT_MOST_GCC48
163 #define PEPTIDE_AT_MOST_GCC48 0
164 #endif
165 
166 #ifndef PEPTIDE_AT_MOST_MSVC2012
167 #define PEPTIDE_AT_MOST_MSVC2012 0
168 #endif
169 
170 #ifndef PEPTIDE_AT_MOST_MSVC2013
171 #define PEPTIDE_AT_MOST_MSVC2013 0
172 #endif
173 
174 #ifndef PEPTIDE_AT_MOST_MSVC2015
175 #define PEPTIDE_AT_MOST_MSVC2015 0
176 #endif
177 
178 
179 //==============================================================================
180 // FEATURE DETECTION
181 //==============================================================================
182 
183 // Stub out __has_feature when not supported by a given compiler
184 #ifndef __has_feature
185 #define __has_feature(x) 0
186 #endif
187 
188 //==============================================================================
189 // COMPILER CAPABILITIES
190 //==============================================================================
191 
192 #if PEPTIDE_AT_MOST_MSVC2013
193  // Neither MSVC 2012 nor 2013 support the C++11 noexcept keyword
194  #define PEPTIDE_NOEXCEPT
195 #else
196  #define PEPTIDE_NOEXCEPT noexcept
204 #endif
205 
206 #if PEPTIDE_AT_MOST_MSVC2013
207  // Neither MSVC 2012 nor 2013 support the C++11 constexpr keyword
208  #define PEPTIDE_CONSTEXPR
209 #else
210  #define PEPTIDE_CONSTEXPR constexpr
218 #endif
219 
224 #if __has_feature(cxx_rtti) || defined(__GXX_RTTI) || defined(_CPPRTTI)
225 #define PEPTIDE_HAS_CXX_RTTI 1
226 #else
227 #define PEPTIDE_HAS_CXX_RTTI 0
228 #endif
229 
230 #if !PEPTIDE_IS_MSC || !PEPTIDE_AT_MOST_MSVC2012
231 
238 #define PEPTIDE_HAS_TEMPLATE_ALIASES 1
239 
247 #define PEPTIDE_HAS_EXPLICIT_CONVERSION_OPERATORS 1
248 
256 #define PEPTIDE_HAS_VARIADIC_TEMPLATE 1
257 
266 #define PEPTIDE_HAS_DEFAULTED_FUNCTIONS 1
267 
276 #define PEPTIDE_HAS_DELETED_FUNCTIONS 1
277 
278 #else
279 
280 // MSVC 2012 does not support C++11 template aliases.
281 #define PEPTIDE_HAS_TEMPLATE_ALIASES 0
282 
283 // MSVC 2012 does not support C++11 explicit conversion operators.
284 #define PEPTIDE_HAS_EXPLICIT_CONVERSION_OPERATORS 0
285 
286 // MSVC 2012 does not support C++11 variadic templates.
287 #define PEPTIDE_HAS_VARIADIC_TEMPLATE 0
288 
289 // MSVC 2012 does not support C++11 defaulted functions.
290 #define PEPTIDE_HAS_DEFAULTED_FUNCTIONS 0
291 
292 // MSVC 2012 does not support C++11 deleted functions.
293 #define PEPTIDE_HAS_DELETED_FUNCTIONS 0
294 
295 #endif
296 
297 
303 #if PEPTIDE_IS_MSC || PEPTIDE_IS_INTEL
304 
305 #define PEPTIDE_FORCEINLINE __forceinline
306 
307 #elif PEPTIDE_IS_GCC || PEPTIDE_IS_CLANG
308 
309 #define PEPTIDE_FORCEINLINE inline __attribute__((always_inline))
310 
311 #endif
312 
313 
314 //==============================================================================
315 // COMPILER WORKAROUNDS
316 //==============================================================================
317 
318 //------------------------------------------------------------------------------
319 //
320 #if !PEPTIDE_HAS_VARIADIC_TEMPLATE
321 
324 #define PEPTIDE_APPLY_0(APPLY, JOIN)
325 #define PEPTIDE_APPLY_1(APPLY, JOIN) APPLY(1)
326 #define PEPTIDE_APPLY_2(APPLY, JOIN) JOIN(PEPTIDE_APPLY_1(APPLY,JOIN),APPLY(2))
327 #define PEPTIDE_APPLY_3(APPLY, JOIN) JOIN(PEPTIDE_APPLY_2(APPLY,JOIN),APPLY(3))
328 #define PEPTIDE_APPLY_4(APPLY, JOIN) JOIN(PEPTIDE_APPLY_3(APPLY,JOIN),APPLY(4))
329 #define PEPTIDE_APPLY_5(APPLY, JOIN) JOIN(PEPTIDE_APPLY_4(APPLY,JOIN),APPLY(5))
330 #define PEPTIDE_APPLY_6(APPLY, JOIN) JOIN(PEPTIDE_APPLY_5(APPLY,JOIN),APPLY(6))
331 #define PEPTIDE_APPLY_7(APPLY, JOIN) JOIN(PEPTIDE_APPLY_6(APPLY,JOIN),APPLY(7))
332 #define PEPTIDE_APPLY_8(APPLY, JOIN) JOIN(PEPTIDE_APPLY_7(APPLY,JOIN),APPLY(8))
333 
334 #define PEPTIDE_VARIADIC_TEMPLATE_EXPAND(CODE_MACRO) \
335  CODE_MACRO(PEPTIDE_APPLY_0) \
336  CODE_MACRO(PEPTIDE_APPLY_1) \
337  CODE_MACRO(PEPTIDE_APPLY_2) \
338  CODE_MACRO(PEPTIDE_APPLY_3) \
339  CODE_MACRO(PEPTIDE_APPLY_4) \
340  CODE_MACRO(PEPTIDE_APPLY_5) \
341  CODE_MACRO(PEPTIDE_APPLY_6) \
342  CODE_MACRO(PEPTIDE_APPLY_7) \
343  CODE_MACRO(PEPTIDE_APPLY_8)
344 
345 #define PEPTIDE_JOIN_COMMA(A,B) A, B
346 #define PEPTIDE_JOIN(A,B) A B
347 
348 #define PEPTIDE_TPARAMS(N) , class A##N
349 #define PEPTIDE_RV_PARAMS(N) A##N&& a##N
350 #define PEPTIDE_FWD_ARGS(N) std::forward<A##N>(a##N)
351 
352 #define PEPTIDE_TPARAMS_EXPAND(ARGS) ARGS(PEPTIDE_TPARAMS, PEPTIDE_JOIN)
353 #define PEPTIDE_RV_PARAMS_EXPAND(ARGS) ARGS(PEPTIDE_RV_PARAMS,PEPTIDE_JOIN_COMMA)
354 #define PEPTIDE_FWD_ARGS_EXPAND(ARGS) ARGS(PEPTIDE_FWD_ARGS, PEPTIDE_JOIN_COMMA)
355 
357 #endif
358 
359 //==============================================================================
360 // EXPORT DIRECTIVES
361 //==============================================================================
362 
368 #if PEPTIDE_IS_GCC || PEPTIDE_IS_CLANG
369 #define PEPTIDE_EXPORT_UNIX __attribute__((visibility("default")))
370 #else
371 #define PEPTIDE_EXPORT_UNIX
372 #endif
373 
374 #endif