1+ #pragma once
2+
3+ #include " compiler.hpp"
4+
5+ #define RSL_STRINGIZE_IMPL (x ) #x
6+ #define RSL_STRINGIZE (x ) RSL_STRINGIZE_IMPL(x)
7+ #if RSL_COMPILER == RSL_COMPILER_MSVC
8+ # define RSL_PRAGMA (x ) __pragma(x)
9+ #else
10+ # define RSL_PRAGMA (x ) _Pragma (RSL_STRINGIZE(x))
11+ #endif
12+
13+
14+ #if RSL_COMPILER == RSL_COMPILER_MSVC
15+ # define RSL_DIAG_PUSH RSL_PRAGMA (warning(push))
16+ # define RSL_DIAG_POP RSL_PRAGMA (warning(pop))
17+ # define RSL_DIAG_DISABLE (id ) RSL_PRAGMA(warning(disable : RSL_DIAGS_##id))
18+ # define RSL_DIAG_ERROR (id ) RSL_PRAGMA(warning(error : RSL_DIAGS_##id))
19+ #elif RSL_COMPILER == RSL_COMPILER_GCC || RSL_COMPILER == RSL_COMPILER_CLANG
20+ # define RSL_DIAG_PUSH RSL_PRAGMA (RSL_COMPILER_ID diagnostic push)
21+ # define RSL_DIAG_POP RSL_PRAGMA (RSL_COMPILER_ID diagnostic pop)
22+ # define RSL_DIAG_DISABLE (w ) RSL_PRAGMA(RSL_COMPILER_ID diagnostic ignored RSL_DIAGS_##w)
23+ # define RSL_DIAG_ERROR (w ) RSL_PRAGMA(RSL_COMPILER_ID diagnostic error RSL_DIAGS_##w)
24+ #else
25+ # warning "Unsupported compiler"
26+ #endif
27+
28+ #define RSL_IMPL_CONSUME (...)
29+ #define RSL_DIAG_push RSL_DIAG_PUSH RSL_IMPL_CONSUME
30+ #define RSL_DIAG_pop RSL_DIAG_POP RSL_IMPL_CONSUME
31+ #define RSL_DIAG_disable RSL_DIAG_DISABLE
32+ #define RSL_DIAG_error RSL_DIAG_ERROR
33+
34+ // Diagnostic map
35+ #if RSL_COMPILER == RSL_COMPILER_MSVC
36+ # define RSL_DIAGS_literal_suffix 4455
37+ # define RSL_DIAGS_narrowing 4838
38+ #elif RSL_COMPILER == RSL_COMPILER_GCC
39+ # define RSL_DIAGS_literal_suffix " -Wliteral-suffix"
40+ # define RSL_DIAGS_narrowing " -Wnarrowing"
41+ #elif RSL_COMPILER == RSL_COMPILER_CLANG
42+ # define RSL_DIAGS_literal_suffix " -Wuser-defined-literals"
43+ # define RSL_DIAGS_narrowing " -Wc++11-narrowing"
44+ #else
45+ # warning "Unsupported compiler"
46+ #endif
0 commit comments