olp-cpp-sdk  1.22.0
warning_disable.h
1 /*
2  * Copyright (C) 2019 HERE Europe B.V.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * SPDX-License-Identifier: Apache-2.0
17  * License-Filename: LICENSE
18  */
19 
20 #pragma once
21 
22 // MSVC Specific
23 #if defined( _MSC_VER )
24 #define PORTING_MSVC_DISABLE_WARNINGS( a ) __pragma( warning( disable : a ) )
25 
26 #define PORTING_MSVC_PUSH_WARNINGS( ) __pragma( warning( push ) )
27 
28 #define PORTING_MSVC_POP_WARNINGS( ) __pragma( warning( pop ) )
29 
30 #else
31 #define PORTING_MSVC_DISABLE_WARNINGS( a )
32 #define PORTING_MSVC_PUSH_WARNINGS( )
33 #define PORTING_MSVC_POP_WARNINGS( )
34 #endif
35 
36 // Needed for concating args for clang and gcc
37 #if defined( __GNUC__ )
38 #define PORTING_DO_PRAGMA_( x ) _Pragma( #x )
39 #define PORTING_DO_PRAGMA( x ) PORTING_DO_PRAGMA_( x )
40 #endif
41 
42 // CLANG Specific
43 #if defined( __clang__ )
44 #define PORTING_CLANG_DISABLE_WARNING( arg ) PORTING_DO_PRAGMA( clang diagnostic ignored arg )
45 
46 #define PORTING_CLANG_PUSH_WARNINGS( ) PORTING_DO_PRAGMA( clang diagnostic push )
47 
48 #define PORTING_CLANG_POP_WARNINGS( ) PORTING_DO_PRAGMA( clang diagnostic pop )
49 
50 #else
51 #define PORTING_CLANG_DISABLE_WARNING( a )
52 #define PORTING_CLANG_PUSH_WARNINGS( )
53 #define PORTING_CLANG_POP_WARNINGS( )
54 #endif
55 
56 // GNU Specific
57 #if defined( __GNUC__ ) && !defined( __clang__ )
58 #define PORTING_GCC_DISABLE_WARNING( arg ) PORTING_DO_PRAGMA( GCC diagnostic ignored arg )
59 
60 #define PORTING_GCC_PUSH_WARNINGS( ) PORTING_DO_PRAGMA( GCC diagnostic push )
61 
62 #define PORTING_GCC_POP_WARNINGS( ) PORTING_DO_PRAGMA( GCC diagnostic pop )
63 
64 #else
65 #define PORTING_GCC_DISABLE_WARNING( a )
66 #define PORTING_GCC_PUSH_WARNINGS( )
67 #define PORTING_GCC_POP_WARNINGS( )
68 #endif
69 
70 // for both gcc and clang
71 #if defined( __GNUC__ )
72 #define PORTING_CLANG_GCC_DISABLE_WARNING( arg ) PORTING_DO_PRAGMA( GCC diagnostic ignored arg )
73 #else
74 #define PORTING_CLANG_GCC_DISABLE_WARNING( a )
75 #endif
76 
77 // helper state maintaining macros
78 #define PORTING_PUSH_WARNINGS( ) \
79  PORTING_CLANG_PUSH_WARNINGS( ) \
80  PORTING_GCC_PUSH_WARNINGS( ) \
81  PORTING_MSVC_PUSH_WARNINGS( )
82 
83 #define PORTING_POP_WARNINGS( ) \
84  PORTING_CLANG_POP_WARNINGS( ) \
85  PORTING_GCC_POP_WARNINGS( ) \
86  PORTING_MSVC_POP_WARNINGS( )