fork download
  1. #define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
  2. #define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
  3.  
  4. #define IIF(c) PRIMITIVE_CAT(IIF_, c)
  5. #define IIF_0(t, ...) __VA_ARGS__
  6. #define IIF_1(t, ...) t
  7.  
  8. #define PROBE(x) x, 1
  9.  
  10. #define CHECK(...) CHECK_N(__VA_ARGS__, 0)
  11. #define CHECK_N(x, n, ...) n
  12.  
  13. #define ENABLE_USER_gwiazdorrr () // gwiazdorrr is now enabled
  14. #define ENABLE_USER_foo () // foo is also enabled
  15. // #define ENABLE_USER_bar () // bar is NOT enabled
  16.  
  17. #define USER_ENABLED_PROBE(user) USER_ENABLED_PROBE_PROXY( ENABLE_USER_##user ) // concatenate prefix with user name
  18. #define USER_ENABLED_PROBE_PROXY(...) USER_ENABLED_PROBE_PRIMIVIE(__VA_ARGS__) // expand arguments
  19. #define USER_ENABLED_PROBE_PRIMIVIE(x) USER_ENABLED_PROBE_COMBINE_ x // merge
  20. #define USER_ENABLED_PROBE_COMBINE_(...) PROBE(~) // if merge successful, expand to probe
  21.  
  22. #define IS_USER_ENABLED(user) CHECK(USER_ENABLED_PROBE(user))
  23.  
  24.  
  25. #define TURN_OPTIMISATION_OFF(user) IIF( IS_USER_ENABLED(user) ) \
  26.   (\
  27.   _Pragma ("GCC optimize \"0\""),\
  28.   /* nothing */ \
  29.   )
  30.  
  31. TURN_OPTIMISATION_OFF(gwiazdorrr) // expands into __pragma optimize("", off)
  32. TURN_OPTIMISATION_OFF(foo) // expands into __pragma optimize("", off)
  33. TURN_OPTIMISATION_OFF(bar) // nothing emitted
  34.  
  35. int main()
  36. {
  37. return 0;
  38. }
Success #stdin #stdout 0.02s 2720KB
stdin
Standard input is empty
stdout

Standard output is empty