Psi4
pragma.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2018 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
30 
31 #ifndef PULSAR_GUARD_PULSAR__PRAGMA_H_
32 #define PULSAR_GUARD_PULSAR__PRAGMA_H_
33 
34 // clang-format off
35 #if defined(__ICC) || defined(__INTEL_COMPILER)
36 
37 // pragmas for Intel
38 #define PRAGMA_WARNING_POP _Pragma("warning(pop)")
39 #define PRAGMA_WARNING_PUSH _Pragma("warning(push)")
40 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS _Pragma("warning(disable:869)")
41 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES _Pragma("warning(disable:177)")
42 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY _Pragma("warning(disable:1572)")
43 #define PRAGMA_WARNING_IGNORE_FP_CONVERT _Pragma("warning(disable:264 173)")
44 #define PRAGMA_WARNING_IGNORE_CONVERT _Pragma("warning(disable:2259)")
45 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT _Pragma("warning(disable:2338)")
46 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0 _Pragma("warning(disable:186)")
47 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE _Pragma("warning(disable:111)")
48 #define PRAGMA_WARNING_IGNORE_SHADOW _Pragma("warning(disable:1599)")
49 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER _Pragma("warning(disable:3280)")
50 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON // does not have warning for intel
51 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE _Pragma("warning(disable:522)")
52 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS
53 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA _Pragma("warning(disable:2282)")
54 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR _Pragma("warning(disable:444)")
55 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION
56 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA _Pragma("warning(disable:161)")
57 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS _Pragma("warning(disable:1478)")
58 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL
59 
60 #elif defined(__clang__) // Do clang before GNU because clang defines __GNUC__, too.
61 
62 #define PRAGMA_WARNING_PUSH _Pragma("clang diagnostic push")
63 #define PRAGMA_WARNING_POP _Pragma("clang diagnostic pop")
64 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS _Pragma("clang diagnostic ignored \"-Wunused-parameter\"")
65 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES _Pragma("clang diagnostic ignored \"-Wunused-variable\"")
66 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY _Pragma("clang diagnostic ignored \"-Wfloat-equal\"")
67 #define PRAGMA_WARNING_IGNORE_FP_CONVERT _Pragma("clang diagnostic ignored \"-Wfloat-conversion\"")
68 #define PRAGMA_WARNING_IGNORE_CONVERT _Pragma("clang diagnostic ignored \"-Wconversion\"")
69 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT _Pragma("clang diagnostic ignored \"-Wswitch-default\"")
70 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0 _Pragma("clang diagnostic ignored \"-Wtype-limits\"")
71 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE
72 #define PRAGMA_WARNING_IGNORE_SHADOW _Pragma("clang diagnostic ignored \"-Wshadow\"")
73 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER
74 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON _Pragma("clang diagnostic ignored \"-Wpedantic\"")
75 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE // does not have warning for clang
76 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS _Pragma("clang diagnostic ignored \"-Wunused-local-typedefs\"")
77 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA // uh... not a warning in gcc
78 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR // Doesn't seem to warn in clang
79 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
80 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
81 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
82 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL _Pragma("clang diagnostic ignored \"-Woverloaded-virtual\"")
83 
84 #elif defined(__GNUC__) || defined(__GNUG__)
85 
86 // pragmas for GCC
87 #define PRAGMA_WARNING_PUSH _Pragma("GCC diagnostic push")
88 #define PRAGMA_WARNING_POP _Pragma("GCC diagnostic pop")
89 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
90 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
91 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
92 #define PRAGMA_WARNING_IGNORE_FP_CONVERT _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"")
93 #define PRAGMA_WARNING_IGNORE_CONVERT _Pragma("GCC diagnostic ignored \"-Wconversion\"")
94 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT _Pragma("GCC diagnostic ignored \"-Wswitch-default\"")
95 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0 _Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
96 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE
97 #define PRAGMA_WARNING_IGNORE_SHADOW _Pragma("GCC diagnostic ignored \"-Wshadow\"")
98 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER
99 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
100 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE // does not have warning for GCC
101 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS _Pragma("GCC diagnostic ignored \"-Wunused-local-typedefs\"")
102 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA // uh... not a warning in gcc
103 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR // Doesn't seem to warn in GCC
104 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
105 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
106 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
107 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL
108 
109 #elif defined(_MSC_VER)
110 
111 // pragmas for Microsoft Visual Compiler (MSVC)
112 #define PRAGMA_WARNING_PUSH
113 #define PRAGMA_WARNING_POP
114 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS
115 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES
116 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY
117 #define PRAGMA_WARNING_IGNORE_FP_CONVERT
118 #define PRAGMA_WARNING_IGNORE_CONVERT
119 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT
120 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0
121 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE
122 #define PRAGMA_WARNING_IGNORE_SHADOW
123 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER
124 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON
125 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE
126 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS
127 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA
128 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR
129 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION
130 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA
131 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
132 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL
133 
134 #endif
135 // clang-format on
136 
137 // The following is adapted from https://gcc.gnu.org/wiki/Visibility the step-by-step guide at the very bottom
138 // Visibility macros
139 #if defined _WIN32 || defined __CYGWIN__
140 #define PSI_HELPER_SO_EXPORT __declspec(dllexport)
141 #define PSI_HELPER_SO_LOCAL
142 #else
143 #if __GNUC__ >= 4
144 #define PSI_HELPER_SO_EXPORT __attribute__((visibility("default")))
145 #define PSI_HELPER_SO_LOCAL __attribute__((visibility("hidden")))
146 #else
147 #define PSI_HELPER_SO_EXPORT
148 #define PSI_HELPER_SO_LOCAL
149 #endif
150 #endif
151 
152 // Use generic helper definitions to define PSI_API and PSI_LOCAL
153 // PSI_API is used for the public API symbols.
154 // PSI_LOCAL is used for non-API symbols.
155 #define PSI_API PSI_HELPER_SO_EXPORT
156 #define PSI_LOCAL PSI_HELPER_SO_LOCAL
157 
158 #endif