1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 // clang-format off 17 18 19 // compile and version specific, warning available since vs 2022 20 #if defined(__clang__) || defined(__GNUC__) 21 #define W_SUPPRESS_UNUSED _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") 22 #elif defined(_MSC_VER) && _MSC_VER > 1934 23 #define W_SUPPRESS_UNUSED _Pragma ("warning(disable : 5264)") 24 #elif defined(_MSC_VER) && _MSC_VER <= 1934 25 #define W_SUPPRESS_UNUSED 26 #else 27 #define W_SUPPRESS_UNUSED 28 #endif 29 30 // compile and version specific, warning available since vs 2017 31 #if defined(__clang__) || defined(__GNUC__) 32 #define W_THIS_USED_BASE_INITIALIZER_LIST 33 #elif defined(_MSC_VER) && _MSC_VER > 1934 34 #define W_THIS_USED_BASE_INITIALIZER_LIST _Pragma ("warning(disable : 4355)") 35 #elif defined(_MSC_VER) && _MSC_VER <= 1934 36 #define W_THIS_USED_BASE_INITIALIZER_LIST __pragma(warning(disable:4355)) 37 #else 38 #define W_THIS_USED_BASE_INITIALIZER_LIST 39 #endif 40 41 // compile and version specific push and pop scopes 42 #if defined(__clang__) || defined(__GNUC__) 43 #define WARNING_SCOPE_START(...) \ 44 _Pragma("GCC diagnostic push"); \ 45 __VA_ARGS__; 46 #define WARNING_SCOPE_END() _Pragma("GCC diagnostic pop"); 47 #elif defined(_MSC_VER) && _MSC_VER > 1916 48 #define WARNING_SCOPE_START(...) \ 49 _Pragma("warning(push)"); \ 50 ##__VA_ARGS__; 51 #define WARNING_SCOPE_END() _Pragma("warning(pop)"); 52 #elif defined(_MSC_VER) && _MSC_VER <= 1916 53 #define WARNING_SCOPE_START(...) \ 54 __pragma(warning(push)) ; \ 55 ##__VA_ARGS__; 56 #define WARNING_SCOPE_END() __pragma(warning(pop)) ; 57 #else 58 #define WARNING_SCOPE_START(...) 59 #define WARNING_SCOPE_END() 60 #endif 61 // clang-format on