MCKL
Monte Carlo Kernel Library
compiler.h
Go to the documentation of this file.
1 //============================================================================
2 // MCKL/include/mckl/internal/compiler.h
3 //----------------------------------------------------------------------------
4 // MCKL: Monte Carlo Kernel Library
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2018, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef MCKL_INTERNAL_COMPILER_H
33 #define MCKL_INTERNAL_COMPILER_H
34 
36 #if defined(__OPENCL_VERSION__)
37 #define MCKL_OPENCL
39 #elif defined(__INTEL_COMPILER)
40 #define MCKL_INTEL
42 #elif defined(__clang__)
43 #define MCKL_CLANG
45 #elif defined(__GNUC__)
46 #define MCKL_GCC
48 #endif
51 
52 #ifndef MCKL_INLINE
53 #define MCKL_INLINE
54 #endif
55 
56 #ifndef MCKL_INLINE_CALL
57 #define MCKL_INLINE_CALL
58 #endif
59 
60 #define MCKL_PRAGMA(x) _Pragma(#x)
61 
62 #ifdef MCKL_CLANG
63 #define MCKL_PUSH_CLANG_WARNING(warning) \
64  MCKL_PRAGMA(clang diagnostic push) \
65  MCKL_PRAGMA(clang diagnostic ignored warning)
66 #define MCKL_POP_CLANG_WARNING MCKL_PRAGMA(clang diagnostic pop)
67 #else
68 #define MCKL_PUSH_CLANG_WARNING(warning)
69 #define MCKL_POP_CLANG_WARNING
70 #endif
71 
72 #ifdef MCKL_GCC
73 #define MCKL_PUSH_GCC_WARNING(warning) \
74  MCKL_PRAGMA(GCC diagnostic push) \
75  MCKL_PRAGMA(GCC diagnostic ignored warning)
76 #define MCKL_POP_GCC_WARNING MCKL_PRAGMA(GCC diagnostic pop)
77 #else
78 #define MCKL_PUSH_GCC_WARNING(warning)
79 #define MCKL_POP_GCC_WARNING
80 #endif
81 
82 #ifdef MCKL_INTEL
83 #define MCKL_PUSH_INTEL_WARNING(wid) \
84  MCKL_PRAGMA(warning(push)) \
85  MCKL_PRAGMA(warning(disable : wid))
86 #define MCKL_POP_INTEL_WARNING MCKL_PRAGMA(warning(pop))
87 #else
88 #define MCKL_PUSH_INTEL_WARNING(wid)
89 #define MCKL_POP_INTEL_WARNING
90 #endif
91 
92 MCKL_PUSH_CLANG_WARNING("-Wc++98-compat")
93 MCKL_PUSH_CLANG_WARNING("-Wc++98-compat-pedantic")
94 MCKL_PUSH_CLANG_WARNING("-Wc++11-compat")
95 MCKL_PUSH_CLANG_WARNING("-Wc++11-compat-pedantic")
96 
97 MCKL_PUSH_INTEL_WARNING(383) // reference to temporary used
98 MCKL_PUSH_INTEL_WARNING(444) // destructor for base class is not virtual
99 MCKL_PUSH_INTEL_WARNING(981) // operands are evaluated in unspecified order
100 
101 #endif // MCKL_INTERNAL_COMPILER_HPP
#define MCKL_PUSH_CLANG_WARNING(warning)
Definition: compiler.h:63
#define MCKL_PUSH_INTEL_WARNING(wid)
Definition: compiler.h:88