Last active
August 29, 2015 14:02
-
-
Save kisel/b6f4f371a0125dc67d5a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
usage: | |
gcc -o show_c_sizeof show_c_sizeof.c && ./show_c_sizeof | |
*/ | |
#include <stdio.h> | |
#define S(type) \ | |
printf("sizeof(" #type ") = %d\n", (int)(sizeof(type))) | |
int main() | |
{ | |
S(bool); | |
S(char); | |
S(short); | |
S(int); | |
S(long); | |
S(long long); | |
S(size_t); | |
return 0; | |
} |
This file contains hidden or 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
## 32bit system | |
sizeof(char) = 1 | |
sizeof(short) = 2 | |
sizeof(int) = 4 | |
sizeof(long) = 4 | |
sizeof(long long) = 8 | |
sizeof(size_t) = 4 | |
## 64 bit Linux | |
sizeof(char) = 1 | |
sizeof(short) = 2 | |
sizeof(int) = 4 | |
sizeof(long) = 8 | |
sizeof(long long) = 8 | |
sizeof(size_t) = 8 | |
## 64 bit Mac OS | |
sizeof(char) = 1 | |
sizeof(short) = 2 | |
sizeof(int) = 4 | |
sizeof(long) = 8 | |
sizeof(long long) = 8 | |
sizeof(size_t) = 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment