fork(2) download
  1. /*
  2.  * For http://stackoverflow.com/a/15448781/545027
  3.  * -- Eldar
  4.  */
  5.  
  6. #define __type_is_void(expr) __builtin_types_compatible_p(typeof(expr), void)
  7. #define __expr_or_zero(expr) __builtin_choose_expr(__type_is_void(expr), 0, (expr))
  8.  
  9. #define DO(expr) \
  10.   __builtin_choose_expr(__type_is_void(expr), \
  11. __DO_VOID(expr), \
  12. __DO(__expr_or_zero(expr)))
  13.  
  14. #define __DO(expr) \
  15. ({ typeof(expr) __ret; __ret = (expr); __ret; })
  16.  
  17. #define __DO_VOID(expr) \
  18. (void) (expr)
  19.  
  20. void foo(void) { }
  21. int bar(void) { return 1; }
  22.  
  23. int main(void) {
  24. DO(foo());
  25. DO(bar());
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 1828KB
stdin
Standard input is empty
stdout
Standard output is empty