Typesize.txt

From WTFwiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This pages records the results obtained by compiling and running typesize.c on various platforms. If you have access to an OS/Platform not listed, feel free to add additional results.

                short   int     long    long^2  float   double  long double
Minix/i286      2       2       4       N/A     4       8       8
Minix/i486      2       4       4       N/A     4       8       8
FreeBSD/i686    2       4       4       8       4       8       12
OpenBSD/amd64   2       4       8       8       4       8       16
NetBSD/sparc32  2       4       4       8       4       8       8
OpenBSD/sparc64 2       4       8       8       4       8       16
NetBSD/alpha    2       4       8       8       4       8       8
HP-UX/hppa      2       4       4       8       4       8       8
AIX/power/32bit 2       4       4       8       4       8       8
AIX/power/64bit 2       4       8       8       4       8       8
IRIX/mips       2       4       4       8       4       8       16

typesize.c

#include <stdio.h>

int main(void)
{
        char ca;
        short int ia;
        int ib;
        long int ic;
        long long int id;
        float fa;
        double da;
        long double db;


        printf("sizeof(char): %d\n", sizeof(ca));
        printf("sizeof(short int): %d\nsizeof(int): %d\nsizeof(long int): %d\nsizeof(long long int): %d\n",sizeof(ia), sizeof(ib), sizeof(ic), sizeof(id));
        printf("sizeof(float): %d\n", sizeof(fa));
        printf("sizeof(double): %d\nsizeof(long double): %d\n", sizeof(da), sizeof(db));

        return 0;
}