Skip to content

Commit 36330cf

Browse files
committed
silency compiler warnings for gcc 4.7 and before
The option -Wliteral-suffix was introduced in gcc 4.8, and "#pragma GCC diagnostic push" was added in 4.6. Using the header with an older gcc would lead to warnings like: string_view.hpp:438: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' string_view.hpp:439: warning: unknown option after '#pragma GCC diagnostic' kind string_view.hpp:1681: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic'
1 parent 6e90d37 commit 36330cf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

include/nonstd/string_view.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,10 @@ using std::operator<<;
435435
# pragma clang diagnostic push
436436
# pragma clang diagnostic ignored "-Wuser-defined-literals"
437437
#elif defined(__GNUC__)
438-
# pragma GCC diagnostic push
439-
# pragma GCC diagnostic ignored "-Wliteral-suffix"
438+
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
439+
# pragma GCC diagnostic push
440+
# pragma GCC diagnostic ignored "-Wliteral-suffix"
441+
# endif
440442
#endif // __clang__
441443

442444
#if nssv_COMPILER_MSVC_VERSION >= 140
@@ -452,7 +454,11 @@ using std::operator<<;
452454
#if defined(__clang__)
453455
# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop")
454456
#elif defined(__GNUC__)
455-
# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
457+
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
458+
# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
459+
# else
460+
# define nssv_RESTORE_WARNINGS()
461+
# endif
456462
#elif nssv_COMPILER_MSVC_VERSION >= 140
457463
# define nssv_RESTORE_WARNINGS() __pragma(warning(pop ))
458464
#else

0 commit comments

Comments
 (0)