fork(2) download
  1. #include <stdio.h>
  2.  
  3. #define PICK_SET_A
  4.  
  5. #ifdef PICK_SET_A
  6. #define SET A
  7. #endif
  8. #ifdef PICK_SET_B
  9. #define SET B
  10. #endif
  11.  
  12. #define ENABLE_VAR_1_A 1
  13. #define ENABLE_VAR_2_A 1
  14.  
  15. #define ENABLE_VAR_2_B 0
  16. #define ENABLE_VAR_2_B 0
  17.  
  18. #define MACRO_RESOLVE__(M) M
  19. #define MACRO_RESOLVE_(V, S) MACRO_RESOLVE__(ENABLE_VAR_ ## V ##_## S)
  20. #define MACRO_RESOLVE(var,set) MACRO_RESOLVE_(var, set)
  21.  
  22. #define ENABLE_VAR_1 MACRO_RESOLVE(1, SET)
  23. #define ENABLE_VAR_2 MACRO_RESOLVE(2, SET)
  24.  
  25. int main(int argc, char **argv) {
  26.  
  27. fprintf(stdout, "VALUE: %d\n", ENABLE_VAR_1);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 2160KB
stdin
Standard input is empty
stdout
VALUE: 1