boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

027-sizeof-types.c (597B)


      1 // tests/cc-parse/27-sizeof-types.c — sizeof over struct, array, ptr,
      2 // char, plus the named integer types (§C.2). Sums to a known total for
      3 // the active data model (51 on LP64, 43 on ILP32).
      4 struct S { int a; int b; };
      5 int main(void) {
      6     int sum = 0;
      7     sum += sizeof(char);            // 1
      8     sum += sizeof(short);           // 2
      9     sum += sizeof(int);             // 4
     10     sum += sizeof(long);            // LP64: 8, ILP32: 4
     11     sum += sizeof(int *);           // LP64: 8, ILP32: 4
     12     sum += sizeof(int[5]);          // 20
     13     sum += sizeof(struct S);        // 8
     14     return sum;
     15 }