Created
February 7, 2022 09:03
-
-
Save sreimers/14eeb8e20dd3f65997be046b4f90bbb2 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
#define __format(arg) _Generic((arg), \ | |
char: "%c", \ | |
signed char: "%hhd", \ | |
unsigned char: "%hhu", \ | |
signed short: "%hd", \ | |
unsigned short: "%hu", \ | |
signed int: "%d", \ | |
unsigned int: "%u", \ | |
long int: "%ld", \ | |
unsigned long int: "%lu", \ | |
long long int: "%lld", \ | |
unsigned long long int: "%llu", \ | |
_Bool: "%d", \ | |
float: "%g", \ | |
double: "%g", \ | |
long double: "%Lg", \ | |
_Complex double: "%g + %gi", \ | |
char *: "%s", \ | |
void *: "%p", \ | |
char[sizeof(arg)]: "%s", \ | |
default: "<unknown>" \ | |
) | |
/* Print an argument regardless of its type (see __format). */ | |
#define __print_arg(arg) printf(__format(arg), arg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment