33 // functions with __attribute__(format) in that case. 34 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ > 4) 35 #ifndef ATTRIBUTE_PRINTF 36 #define ATTRIBUTE_PRINTF(fmt,vargs) __attribute__((format(printf, fmt, vargs))) 37 #endif 38 #ifndef ATTRIBUTE_SCANF 39 #define ATTRIBUTE_SCANF(fmt,vargs) __attribute__((format(scanf, fmt, vargs))) 40 #endif 41 #endif // gcc version check 42 43 #define PRAGMA_DISABLE_GCC_WARNING_AUX(x) _Pragma(#x) 44 #define PRAGMA_DISABLE_GCC_WARNING(option_string) \ 45 PRAGMA_DISABLE_GCC_WARNING_AUX(GCC diagnostic ignored option_string) 46 47 #define PRAGMA_FORMAT_NONLITERAL_IGNORED \ 48 PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \ 49 PRAGMA_DISABLE_GCC_WARNING("-Wformat-security") 50 51 #define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat") 52 53 #if defined(__clang_major__) && \ 54 (__clang_major__ >= 4 || \ 55 (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \ 56 ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) 57 // Tested to work with clang version 3.1 and better. 58 #define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") 59 #define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") 60 61 #endif // clang/gcc version check 62 63 #endif // SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP | 33 // functions with __attribute__(format) in that case. 34 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ > 4) 35 #ifndef ATTRIBUTE_PRINTF 36 #define ATTRIBUTE_PRINTF(fmt,vargs) __attribute__((format(printf, fmt, vargs))) 37 #endif 38 #ifndef ATTRIBUTE_SCANF 39 #define ATTRIBUTE_SCANF(fmt,vargs) __attribute__((format(scanf, fmt, vargs))) 40 #endif 41 #endif // gcc version check 42 43 #define PRAGMA_DISABLE_GCC_WARNING_AUX(x) _Pragma(#x) 44 #define PRAGMA_DISABLE_GCC_WARNING(option_string) \ 45 PRAGMA_DISABLE_GCC_WARNING_AUX(GCC diagnostic ignored option_string) 46 47 #define PRAGMA_FORMAT_NONLITERAL_IGNORED \ 48 PRAGMA_DISABLE_GCC_WARNING("-Wformat-nonliteral") \ 49 PRAGMA_DISABLE_GCC_WARNING("-Wformat-security") 50 51 #define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat") 52 53 // Disable -Wstringop-truncation which is introduced in GCC 8. 54 // https://gcc.gnu.org/gcc-8/changes.html 55 #if (__GNUC__ >= 8) 56 #define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation") 57 #endif 58 59 #if defined(__clang_major__) && \ 60 (__clang_major__ >= 4 || \ 61 (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \ 62 ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4) 63 // Tested to work with clang version 3.1 and better. 64 #define PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") 65 #define PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") 66 67 #endif // clang/gcc version check 68 69 #endif // SHARE_UTILITIES_COMPILERWARNINGS_GCC_HPP |