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 #if defined(__ICC) || defined(__INTEL_COMPILER)
35 
36 // pragmas for Intel
37 #define PRAGMA_WARNING_POP _Pragma("warning(pop)")
38 #define PRAGMA_WARNING_PUSH _Pragma("warning(push)")
39 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS _Pragma("warning(disable:869)")
40 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES _Pragma("warning(disable:177)")
41 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY _Pragma("warning(disable:1572)")
42 #define PRAGMA_WARNING_IGNORE_FP_CONVERT _Pragma("warning(disable:264 173)")
43 #define PRAGMA_WARNING_IGNORE_CONVERT _Pragma("warning(disable:2259)")
44 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT _Pragma("warning(disable:2338)")
45 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0 _Pragma("warning(disable:186)")
46 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE _Pragma("warning(disable:111)")
47 #define PRAGMA_WARNING_IGNORE_SHADOW _Pragma("warning(disable:1599)")
48 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER _Pragma("warning(disable:3280)")
49 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON // does not have warning for intel
50 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE _Pragma("warning(disable:522)")
51 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS
52 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA _Pragma("warning(disable:2282)")
53 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR _Pragma("warning(disable:444)")
54 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION
55 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA _Pragma("warning(disable:161)")
56 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS _Pragma("warning(disable:1478)")
57 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL
58 
59 #elif defined(__clang__) // Do clang before GNU because clang defines __GNUC__, too.
60 
61 #define PRAGMA_WARNING_PUSH _Pragma("clang diagnostic push")
62 #define PRAGMA_WARNING_POP _Pragma("clang diagnostic pop")
63 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS _Pragma("clang diagnostic ignored \"-Wunused-parameter\"")
64 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES _Pragma("clang diagnostic ignored \"-Wunused-variable\"")
65 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY _Pragma("clang diagnostic ignored \"-Wfloat-equal\"")
66 #define PRAGMA_WARNING_IGNORE_FP_CONVERT _Pragma("clang diagnostic ignored \"-Wfloat-conversion\"")
67 #define PRAGMA_WARNING_IGNORE_CONVERT _Pragma("clang diagnostic ignored \"-Wconversion\"")
68 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT _Pragma("clang diagnostic ignored \"-Wswitch-default\"")
69 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0 _Pragma("clang diagnostic ignored \"-Wtype-limits\"")
70 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE
71 #define PRAGMA_WARNING_IGNORE_SHADOW _Pragma("clang diagnostic ignored \"-Wshadow\"")
72 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER
73 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON _Pragma("clang diagnostic ignored \"-Wpedantic\"")
74 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE // does not have warning for clang
75 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS _Pragma("clang diagnostic ignored \"-Wunused-local-typedefs\"")
76 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA // uh... not a warning in gcc
77 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR // Doesn't seem to warn in clang
78 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
79 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
80 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
81 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL _Pragma("clang diagnostic ignored \"-Woverloaded-virtual\"")
82 
83 #elif defined(__GNUC__) || defined(__GNUG__)
84 
85 // pragmas for GCC
86 #define PRAGMA_WARNING_PUSH _Pragma("GCC diagnostic push")
87 #define PRAGMA_WARNING_POP _Pragma("GCC diagnostic pop")
88 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
89 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
90 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
91 #define PRAGMA_WARNING_IGNORE_FP_CONVERT _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"")
92 #define PRAGMA_WARNING_IGNORE_CONVERT _Pragma("GCC diagnostic ignored \"-Wconversion\"")
93 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT _Pragma("GCC diagnostic ignored \"-Wswitch-default\"")
94 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0 _Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
95 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE
96 #define PRAGMA_WARNING_IGNORE_SHADOW _Pragma("GCC diagnostic ignored \"-Wshadow\"")
97 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER
98 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
99 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE // does not have warning for GCC
100 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS _Pragma("GCC diagnostic ignored \"-Wunused-local-typedefs\"")
101 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA // uh... not a warning in gcc
102 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR // Doesn't seem to warn in GCC
103 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
104 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
105 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
106 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL
107 
108 #elif defined(_MSC_VER)
109 
110 // pragmas for Microsoft Visual Compiler (MSVC)
111 #define PRAGMA_WARNING_PUSH
112 #define PRAGMA_WARNING_POP
113 #define PRAGMA_WARNING_IGNORE_UNUSED_PARAMETERS
114 #define PRAGMA_WARNING_IGNORE_UNUSED_VARIABLES
115 #define PRAGMA_WARNING_IGNORE_FP_EQUALITY
116 #define PRAGMA_WARNING_IGNORE_FP_CONVERT
117 #define PRAGMA_WARNING_IGNORE_CONVERT
118 #define PRAGMA_WARNING_IGNORE_SWITCH_MISSING_DEFAULT
119 #define PRAGMA_WARNING_IGNORE_POINTLESS_COMPARISON_UINT_0
120 #define PRAGMA_WARNING_IGNORE_STATEMENT_UNREACHABLE
121 #define PRAGMA_WARNING_IGNORE_SHADOW
122 #define PRAGMA_WARNING_IGNORE_SHADOW_MEMBER
123 #define PRAGMA_WARNING_IGNORE_EXTRA_SEMICOLON
124 #define PRAGMA_WARNING_IGNORE_REDECLARED_INLINE
125 #define PRAGMA_WARNING_IGNORE_UNUSED_LOCAL_TYPEDEFS
126 #define PRAGMA_WARNING_IGNORE_GCC_PRAGMA
127 #define PRAGMA_WARNING_IGNORE_NONVIRTUAL_DTOR
128 #define PRAGMA_WARNING_IGNORE_UNUSED_FUNCTION
129 #define PRAGMA_WARNING_IGNORE_UNRECOGNIZED_PRAGMA
130 #define PRAGMA_WARNING_IGNORE_DEPRECATED_DECLARATIONS
131 #define PRAGMA_WARNING_IGNORE_OVERLOADED_VIRTUAL
132 
133 #endif
134 
135 // The following is adapted from https://gcc.gnu.org/wiki/Visibility the step-by-step guide at the very bottom
136 // Visibility macros
137 #if defined _WIN32 || defined __CYGWIN__
138 # define PSI_HELPER_SO_EXPORT __declspec(dllexport)
139 # define PSI_HELPER_SO_LOCAL
140 #else
141 # if __GNUC__ >= 4
142 # define PSI_HELPER_SO_EXPORT __attribute__ ((visibility ("default")))
143 # define PSI_HELPER_SO_LOCAL __attribute__ ((visibility ("hidden")))
144 # else
145 # define PSI_HELPER_SO_EXPORT
146 # define PSI_HELPER_SO_LOCAL
147 # endif
148 #endif
149 
150 // Use generic helper definitions to define PSI_API and PSI_LOCAL
151 // PSI_API is used for the public API symbols.
152 // PSI_LOCAL is used for non-API symbols.
153 #define PSI_API PSI_HELPER_SO_EXPORT
154 #define PSI_LOCAL PSI_HELPER_SO_LOCAL
155 
156 #endif