-
-
Save kosh04/1218712 to your computer and use it in GitHub Desktop.
#include <stdio.h> | |
#include <stdint.h> | |
#include <stddef.h> | |
#include <sys/types.h> | |
#include <wchar.h> | |
#include <time.h> | |
// XXX: "%zd" format cannot work in VC, MinGW | |
#define prints(type) printf(#type "\t\t" "%lu\n", (unsigned long)sizeof(type)) | |
int main(void) | |
{ | |
printf("Type" "\t\t" "Byte\n"); | |
printf("----\n"); | |
prints(char); | |
prints(char *); | |
prints(short); | |
prints(int); | |
prints(long); | |
prints(long long); | |
prints(float); | |
prints(double); | |
prints(long double); | |
prints(void); | |
prints(void *); | |
prints(size_t); | |
prints(ssize_t); | |
prints(time_t); | |
prints(off_t); | |
prints(wchar_t); | |
prints(intptr_t); | |
prints(ptrdiff_t); | |
prints(_Bool); | |
return 0; | |
} |
// CentOS 5.6 Intel Xeon x86_64-redhat-linux
char 1
char * 8
short 2
int 4
long 8
long long 8
float 4
double 8
long double 16
void 1
void * 8
size_t 8
ssize_t 8
time_t 8
off_t 8
wchar_t 4
intptr_t 8
ptrdiff_t 8
_Bool 1
// FreeBSD 8.2 amd64
char 1
char * 8
short 2
int 4
long 8
long long 8
float 4
double 8
long double 16
void 1
void * 8
size_t 8
ssize_t 8
time_t 8
off_t 8
wchar_t 4
intptr_t 8
ptrdiff_t 8
_Bool 1
// win32 LSI C-86 試食版
char 1
char * 2
short 2
int 2
long 4
long long undef
float 4
double 8
long double 10
void undef
void * 2
size_t 2
ssize_t undef
time_t 4
off_t 4
wchar_t undef
intptr_t undef
ptrdiff_t 2
_Bool undef
// Borland C++ 5.5.1 for Win32
char 1
char * 4
short 2
int 4
long 4
long long undefined
float 4
double 8
long double 10
void undefined
void * 4
size_t 4
ssize_t undefined
time_t 4
off_t 4
wchar_t 2
intptr_t undefined
ptrdiff_t 4
_Bool undefined