Skip to content

Commit 63a5d2a

Browse files
authored
Check gcc version > 7.0 (#950)
1 parent 18957ab commit 63a5d2a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/pal/PAL.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,20 @@ namespace PAL_NS_BEGIN {
398398
char buf[sizeof("YYYY-MM-DDTHH:MM:SS.sssZ") + 1] = { 0 };
399399

400400
#if defined(__GNUC__) && !defined(__clang__)
401+
#include <features.h>
402+
#if __GNUC_PREREQ(7,0) // If gcc_version >= 7.0 https://gcc.gnu.org/gcc-7/changes.html
401403
#pragma GCC diagnostic push
402404
#pragma GCC diagnostic ignored "-Wformat-truncation" // error: 'T' directive output may be truncated writing 1 byte into a region of size between 0 and 16 [-Werror=format-truncation=]
405+
#endif
403406
#endif
404407
(void)snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
405408
1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
406409
tm.tm_hour, tm.tm_min, tm.tm_sec, milliseconds);
407410
#if defined(__GNUC__) && !defined(__clang__)
411+
#if __GNUC_PREREQ(7,0) // If gcc_version >= 7.0 https://gcc.gnu.org/gcc-7/changes.html
408412
#pragma GCC diagnostic pop
409413
#endif
414+
#endif
410415
#endif
411416
return buf;
412417
}

0 commit comments

Comments
 (0)