#define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
#define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
#define IIF(c) PRIMITIVE_CAT(IIF_, c)
#define IIF_0(t, ...) __VA_ARGS__
#define IIF_1(t, ...) t
#define PROBE(x) x, 1
#define CHECK(...) CHECK_N(__VA_ARGS__, 0)
#define CHECK_N(x, n, ...) n
#define ENABLE_USER_gwiazdorrr () // gwiazdorrr is now enabled
#define ENABLE_USER_foo () // foo is also enabled
// #define ENABLE_USER_bar () // bar is NOT enabled
#define USER_ENABLED_PROBE(user) USER_ENABLED_PROBE_PROXY( ENABLE_USER_##user ) // concatenate prefix with user name
#define USER_ENABLED_PROBE_PROXY(...) USER_ENABLED_PROBE_PRIMIVIE(__VA_ARGS__) // expand arguments
#define USER_ENABLED_PROBE_PRIMIVIE(x) USER_ENABLED_PROBE_COMBINE_ x // merge
#define USER_ENABLED_PROBE_COMBINE_(...) PROBE(~) // if merge successful, expand to probe
#define IS_USER_ENABLED(user) CHECK(USER_ENABLED_PROBE(user))
#define TURN_OPTIMISATION_OFF(user) IIF( IS_USER_ENABLED(user) ) \
(\
_Pragma ("GCC optimize \"0\""),\
/* nothing */ \
)
TURN_OPTIMISATION_OFF(gwiazdorrr) // expands into __pragma optimize("", off)
TURN_OPTIMISATION_OFF(foo) // expands into __pragma optimize("", off)
TURN_OPTIMISATION_OFF(bar) // nothing emitted
int main()
{
return 0;
}
I2RlZmluZSBDQVQoYSwgLi4uKSBQUklNSVRJVkVfQ0FUKGEsIF9fVkFfQVJHU19fKQojZGVmaW5lIFBSSU1JVElWRV9DQVQoYSwgLi4uKSBhICMjIF9fVkFfQVJHU19fCgojZGVmaW5lIElJRihjKSBQUklNSVRJVkVfQ0FUKElJRl8sIGMpCiNkZWZpbmUgSUlGXzAodCwgLi4uKSBfX1ZBX0FSR1NfXwojZGVmaW5lIElJRl8xKHQsIC4uLikgdAoKI2RlZmluZSBQUk9CRSh4KSB4LCAxIAoKI2RlZ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