Last active
June 5, 2019 13:23
-
-
Save debuti/d461546ee222d153e0d0a0eaf669746d 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> | |
#include <limits.h> | |
#include <float.h> | |
#include <math.h> | |
#define STRFY(A) #A | |
#define SIZEOFI(T,MIN,MAX) printf("%-20s\t%5zu\t%20lld\t%20llu\n", STRFY(T), sizeof(T), (long long)MIN, (unsigned long long)MAX); | |
#define SIZEOFFP(T,MIN,MAX,RES) printf("%-20s\t%5zu\t%20Lg\t%20Lg\t%20Lg\n", STRFY(T), sizeof(T), (long double)MIN, (long double)MAX, (long double)RES); | |
void main() { | |
enum enu {a}; | |
printf("%-20s\t%5s\t%20s\t%20s\t%20s\n", "GCC "__VERSION__, "Size", "Min", "Max", "Res"); | |
SIZEOFI(enum enu, 0, pow(2, 8*sizeof(enum enu))-1) | |
SIZEOFI(char, CHAR_MIN, CHAR_MAX) | |
SIZEOFI(signed char, SCHAR_MIN, SCHAR_MAX) | |
SIZEOFI(unsigned char, 0, UCHAR_MAX) | |
SIZEOFI(short int, SHRT_MIN, SHRT_MAX) | |
SIZEOFI(unsigned short int, 0, USHRT_MAX) | |
SIZEOFI(int, INT_MIN, INT_MAX) | |
SIZEOFI(unsigned int, 0, UINT_MAX) | |
SIZEOFI(long int, LONG_MIN, LONG_MAX) | |
SIZEOFI(unsigned long int, 0, ULONG_MAX) | |
SIZEOFI(long long int, LLONG_MIN, LLONG_MAX) | |
SIZEOFI(unsigned long long int, 0, ULLONG_MAX) | |
SIZEOFFP(float, FLT_MIN, FLT_MAX, FLT_EPSILON) | |
SIZEOFFP(double, DBL_MIN, DBL_MAX, DBL_EPSILON) | |
SIZEOFFP(long double, LDBL_MIN, LDBL_MAX, LDBL_EPSILON) | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment