pragma.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2021 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
7 #include <mc_rtc/macros/deprecated.h>
8 #include <mc_rtc/macros/pp_id.h>
9 
11 #define MC_RTC_STRINGIFY_(x) #x
12 #define MC_RTC_STRINGIFY(x) MC_RTC_STRINGIFY_(x)
13 
14 #ifndef MC_RTC_PRAGMA
15 # define MC_RTC_PRAGMA(x) _Pragma(MC_RTC_STRINGIFY(x))
16 #endif
17 
19 #define MC_RTC_WN(fun, ...) \
20  MC_RTC_PRAGMA(message(__FILE__ "[" STRING(__LINE__) "] Incorrect number of arguments when invoking macro " STRING( \
21  fun) ". Call is ignored"))
22 
24 #define MC_RTC_MAP2_0(fun)
25 #define MC_RTC_MAP2_1(fun, X, Y) fun(X, Y)
26 #define MC_RTC_MAP2_2(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_1(fun, __VA_ARGS__))
27 #define MC_RTC_MAP2_3(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_2(fun, __VA_ARGS__))
28 #define MC_RTC_MAP2_4(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_3(fun, __VA_ARGS__))
29 #define MC_RTC_MAP2_5(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_4(fun, __VA_ARGS__))
30 #define MC_RTC_MAP2_6(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_5(fun, __VA_ARGS__))
31 #define MC_RTC_MAP2_7(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_6(fun, __VA_ARGS__))
32 #define MC_RTC_MAP2_8(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_7(fun, __VA_ARGS__))
33 #define MC_RTC_MAP2_9(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_8(fun, __VA_ARGS__))
34 #define MC_RTC_MAP2_10(fun, X, Y, ...) fun(X, Y) MC_RTC_PP_ID(MC_RTC_MAP2_9(fun, __VA_ARGS__))
35 
36 #define MC_RTC_GET_MACRO(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \
37  _20, NAME, ...) \
38  NAME
39 
41 #define MC_RTC_MAP_TWO_ARGS(fun, ...) \
42  MC_RTC_PP_ID(MC_RTC_GET_MACRO(_0, __VA_ARGS__, MC_RTC_MAP2_10, MC_RTC_WN, MC_RTC_MAP2_9, MC_RTC_WN, MC_RTC_MAP2_8, \
43  MC_RTC_WN, MC_RTC_MAP2_7, MC_RTC_WN, MC_RTC_MAP2_6, MC_RTC_WN, MC_RTC_MAP2_5, \
44  MC_RTC_WN, MC_RTC_MAP2_4, MC_RTC_WN, MC_RTC_MAP2_3, MC_RTC_WN, MC_RTC_MAP2_2, \
45  MC_RTC_WN, MC_RTC_MAP2_1, MC_RTC_WN, MC_RTC_MAP2_0, MC_RTC_MAP2_0)(fun, __VA_ARGS__))
46 
47 #ifdef __GNUG__
48 # define MC_RTC_diagnostic_push _Pragma("GCC diagnostic push")
49 # define MC_RTC_diagnostic_pop _Pragma("GCC diagnostic pop")
50 # define MC_RTC_GCC_diagnostic_ignored(x) MC_RTC_PRAGMA(GCC diagnostic ignored x)
51 # ifdef __clang__
52 # define MC_RTC_ClangOnly_diagnostic_ignored(x) MC_RTC_PRAGMA(GCC diagnostic ignored x)
53 # define MC_RTC_GCCOnly_diagnostic_ignored(x)
54 # else
55 # define MC_RTC_ClangOnly_diagnostic_ignored(x)
56 # define MC_RTC_GCCOnly_diagnostic_ignored(x) MC_RTC_PRAGMA(GCC diagnostic ignored x)
57 # endif
58 #else
59 # define MC_RTC_GCC_diagnostic_ignored(x)
60 # define MC_RTC_ClangOnly_diagnostic_ignored(x)
61 # define MC_RTC_GCCOnly_diagnostic_ignored(x)
62 #endif
63 
64 #ifdef _MSC_VER
65 # define MC_RTC_diagnostic_push _Pragma("warning(push)")
66 # define MC_RTC_diagnostic_pop _Pragma("warning(pop)")
67 # define MC_RTC_MSVC_diagnostic_ignored(x) MC_RTC_PRAGMA(warning(disable : x))
68 #else
69 # define MC_RTC_MSVC_diagnostic_ignored(x)
70 #endif
71 
73 #define MC_RTC_diagnostic_ignored_(c, w) MC_RTC_##c##_diagnostic_ignored(w)
74 
76 #define MC_RTC_diagnostic_ignored(...) MC_RTC_MAP_TWO_ARGS(MC_RTC_diagnostic_ignored_, __VA_ARGS__)
pp_id.h