fork download
  1. #include <stdio.h>
  2.  
  3. #define DEFLABEL(name) void *name;
  4.  
  5. #define LABELED(retType, fName, labelDefs) labelDefs;\
  6. retType fName
  7.  
  8. #define MKLABEL(name, labelName) name = &&labelName;
  9.  
  10. LABELED(void, test,
  11. DEFLABEL(test_l1)
  12. DEFLABEL(test_l2)
  13. DEFLABEL(test_l3)) (void *ptr) {
  14.  
  15. MKLABEL(test_l1, l1);
  16. MKLABEL(test_l2, l2);
  17. MKLABEL(test_l3, l3);
  18.  
  19. if (ptr)
  20. goto *ptr;
  21. return;
  22. l1:
  23. printf("test1\n");
  24. return;
  25. l2:
  26. printf("test2\n");
  27. return;
  28. l3:
  29. printf("test3\n");
  30. return;
  31. }
  32.  
  33. int main(void) {
  34. test(0);
  35. test(test_l1);
  36. test(test_l2);
  37. test(test_l3);
  38. }
  39.  
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
test1
test2
test3