Debian Codegraph @

research/sizeof.c

raw symbols SCIP
1 /*
2 Simple sizeof experiment to judge appropriate types to replace
3 the DASM chaos with. Looks like we can easily go for "int" all
4 over the place these days. If we want to be compatible with 16
5 bit machines like the Amiga, we may want to go for "long". The
6 best choice might be to typedef "int32_t" to a usable name and
7 stick with that, then we'd only rule out some 8 bit machines.
8 */
9
10 #include <stdbool.h>
11 #include <stdint.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14
15 #define S(type) printf("sizeof(" #type ") == %d\n", sizeof(type))
16
17 int main(void)
18 {
19 S(char);
20 S(int8_t);
21 S(short);
22 S(int16_t);
23 S(int);
24 S(bool);
25 S(long);
26 S(int32_t);
27 S(long long);
28 S(int64_t);
29 S(float);
30 S(double);
31 return EXIT_SUCCESS;
32 }
33
34 /*
35 Darwin Agnes.local 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc PowerBook6,8 Darwin
36
37 sizeof(char) == 1
38 sizeof(int8_t) == 1
39 sizeof(short) == 2
40 sizeof(int16_t) == 2
41 sizeof(int) == 4
42 sizeof(bool) == 4
43 sizeof(long) == 4
44 sizeof(int32_t) == 4
45 sizeof(long long) == 8
46 sizeof(int64_t) == 8
47 sizeof(float) == 4
48 sizeof(double) == 8
49
50 Linux ugradx.cs.jhu.edu 2.6.26.5-45.fc9.i686 #1 SMP Sat Sep 20 03:45:00 EDT 2008 i686 i686 i386 GNU/Linux
51
52 sizeof(char) == 1
53 sizeof(int8_t) == 1
54 sizeof(short) == 2
55 sizeof(int16_t) == 2
56 sizeof(int) == 4
57 sizeof(bool) == 1
58 sizeof(long) == 4
59 sizeof(int32_t) == 4
60 sizeof(long long) == 8
61 sizeof(int64_t) == 8
62 sizeof(float) == 4
63 sizeof(double) == 8
64
65 SunOS peregrine 5.10 Generic_118822-11 sun4u sparc
66
67 sizeof(char) == 1
68 sizeof(int8_t) == 1
69 sizeof(short) == 2
70 sizeof(int16_t) == 2
71 sizeof(int) == 4
72 sizeof(bool) == 1
73 sizeof(long) == 4
74 sizeof(int32_t) == 4
75 sizeof(long long) == 8
76 sizeof(int64_t) == 8
77 sizeof(float) == 4
78 sizeof(double) == 8
79 */