Skip to content

Commit

Permalink
silence compiler warnings for gcc 4.7 and before (#53, thanks @DerDakon)
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
DerDakon authored Oct 12, 2022
1 parent 6e90d37 commit ced5f2e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions include/nonstd/string_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,10 @@ using std::operator<<;
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wuser-defined-literals"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wliteral-suffix"
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wliteral-suffix"
# endif
#endif // __clang__

#if nssv_COMPILER_MSVC_VERSION >= 140
Expand All @@ -452,7 +454,11 @@ using std::operator<<;
#if defined(__clang__)
# define nssv_RESTORE_WARNINGS() _Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
# define nssv_RESTORE_WARNINGS() _Pragma("GCC diagnostic pop")
# else
# define nssv_RESTORE_WARNINGS()
# endif
#elif nssv_COMPILER_MSVC_VERSION >= 140
# define nssv_RESTORE_WARNINGS() __pragma(warning(pop ))
#else
Expand Down

0 comments on commit ced5f2e

Please sign in to comment.