reenable_warnings.h
Go to the documentation of this file.
1 /*
2  Copyright 2014 SINTEF ICT, Applied Mathematics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 // Note: this file shall not have include guards or #pragma once.
21 
22 #ifdef SILENCE_EXTERNAL_WARNINGS
23 
24 // To use this feature, we must have sufficiently new compiler.
25 
26 // Using gcc is ok if version 4.6 or newer.
27 #if defined(__GNUC__)
28 # define __GNUC_VERSION__ (__GNUC__ * 100 \
29  + __GNUC_MINOR__ * 1)
30 # if (__GNUC_VERSION__ >= 406)
31 # define GNU_COMPILER_OK 1
32 # else
33 # define GNU_COMPILER_OK 0
34 # endif
35 #else
36 # define GNU_COMPILER_OK 0
37 #endif
38 
39 // Uncertain what version of clang to require,
40 // assume all versions are fine.
41 #if defined(__clang__)
42 # define CLANG_COMPILER_OK 1
43 #else
44 # define CLANG_COMPILER_OK 0
45 #endif
46 
47 // More compilers can be added here if necessary.
48 #define COMPATIBLE_COMPILER (GNU_COMPILER_OK || CLANG_COMPILER_OK)
49 
50 // If compiler is compatible, pop current warning level.
51 // Note that both clang and (newer) gcc accept the
52 // "#pragma GCC diagnostic" syntax.
53 #if COMPATIBLE_COMPILER
54 #pragma GCC diagnostic pop
55 #endif // COMPATIBLE_COMPILER
56 
57 #endif // SILENCE_EXTERNAL_WARNINGS