Suppress gcc 8 compiler warnings
[fio.git] / nowarn_snprintf.h
1 #ifndef _NOWARN_SNPRINTF_H_
2 #define _NOWARN_SNPRINTF_H_
3
4 #include <stdio.h>
5 #include <stdarg.h>
6
7 static inline int nowarn_snprintf(char *str, size_t size, const char *format,
8                                   ...)
9 {
10         va_list args;
11
12         va_start(args, format);
13 #if __GNUC__ -0 >= 8
14 #pragma GCC diagnostic push "-Wformat-truncation"
15 #pragma GCC diagnostic ignored "-Wformat-truncation"
16 #endif
17         return vsnprintf(str, size, format, args);
18 #if __GNUC__ -0 >= 8
19 #pragma GCC diagnostic pop "-Wformat-truncation"
20 #endif
21         va_end(args);
22 }
23
24 #endif