14 int main(int argc, char *argv[])
18 printf("%d ",sizeof(long));
19 printf("%d ",sizeof(short));
20 printf("%d ",sizeof(int));
31 gcc myctest.c
-o myctest
34 if [ `./myctest |cut -d' ' -f 1` != 4 ]
35 then echo "Error : sizeof(long)!=4"
37 if [ `./myctest |cut -d' ' -f 2` != 2 ]
38 then echo "Error : sizeof(short)!=2"
40 if [ `./myctest |cut -d' ' -f 3` != 4 ]
41 then echo "Error :sizeof(int)!=4"
44 if [ `./myctest |cut -d' ' -f 4` = LITTLE
]
46 echo "#ifndef LITT_ENDIAN" >defendian.h
47 echo "#define LITT_ENDIAN 1" >>defendian.h
48 echo "#endif /* LITT_ENDIAN */" >>defendian.h
49 echo Little Endian machine detected
51 echo "#ifndef LITT_ENDIAN" >defendian.h
52 echo "#endif /* LITT_ENDIAN */" >>defendian.h
53 echo Big Endian machine detected