Created
March 21, 2020 17:58
-
-
Save GoldsteinE/0ac1bb70dd59635b5de9452ca3fcd638 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define IS_INT_LONG(N) _Generic((N), \ | |
int: no_int, \ | |
long int: yes_long, \ | |
long long int: yes_long_long, \ | |
default: no_no_int \ | |
)() | |
void no_int() { | |
puts("No, it's int"); | |
} | |
void yes_long() { | |
puts("Yes, it's long int"); | |
} | |
void yes_long_long() { | |
puts("Yes, it's long long int"); | |
} | |
void no_no_int() { | |
puts("It's not an int at all."); | |
} | |
int main() { | |
int x = 0; | |
long int y = 0; | |
long long int z = 0; | |
char c = 0; | |
IS_INT_LONG(x); | |
IS_INT_LONG(y); | |
IS_INT_LONG(z); | |
IS_INT_LONG(c); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment