disable_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, push current warning level
51 // and ignore warnings that are usually generated from
52 // third-party libraries that are not warning-clean.
53 // Note that both clang and (newer) gcc accept the
54 // "#pragma GCC diagnostic" syntax.
55 #if COMPATIBLE_COMPILER
56 #warning "The disable/enable warnings header files have moved to opm-common"
57 
58 #pragma GCC diagnostic push
59 // Suppress warnings: "unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]".
60 // This is necessary because not all the compilers have the same warning options.
61 #pragma GCC diagnostic ignored "-Wpragmas"
62 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
63 #pragma GCC diagnostic ignored "-Wdeprecated-register"
64 #pragma GCC diagnostic ignored "-Wignored-qualifiers"
65 #pragma GCC diagnostic ignored "-Wmismatched-tags"
66 #pragma GCC diagnostic ignored "-Wshadow"
67 #pragma GCC diagnostic ignored "-Wsign-compare"
68 #pragma GCC diagnostic ignored "-Wunused-parameter"
69 #pragma GCC diagnostic ignored "-Wtautological-compare"
70 #pragma GCC diagnostic ignored "-Wtype-limits"
71 #pragma GCC diagnostic ignored "-Wunused-function"
72 #pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
73 #pragma GCC diagnostic ignored "-Wunused-private-field"
74 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
75 #pragma GCC diagnostic ignored "-Wunused-variable"
76 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
77 #pragma GCC diagnostic ignored "-Wcast-align"
78 #endif // COMPATIBLE_COMPILER
79 
80 #endif // SILENCE_EXTERNAL_WARNINGS