fork download
  1. #include <stdbool.h>
  2. #include <stdint.h>
  3. #include <inttypes.h>
  4.  
  5. // http://stackoverflow.com/questions/7469915
  6. #define IS_UNSIGNED(v) (v >= 0 && ~v >= 0)
  7.  
  8. #define F(v) f(IS_UNSIGNED(v), v, v)
  9.  
  10. void f (bool is_unsigned, intmax_t s, uintmax_t u)
  11. {
  12. if (is_unsigned)
  13. {
  14. printf("%d %" PRIuMAX "\n", is_unsigned, u);
  15. }
  16. else
  17. {
  18. printf("%d %" PRIdMAX "\n", is_unsigned, s);
  19. }
  20. }
  21.  
  22. int main (void)
  23. {
  24. F(INTMAX_MAX);
  25. F(UINTMAX_MAX);
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
0 9223372036854775807
1 18446744073709551615