boot2

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

037-struct-store.c (500B)


      1 // tests/cc-parse/37-struct-store.c — struct member store via real C.
      2 // char-typed fields exercise the width-correct store path; distinct
      3 // multipliers in the readback isolate each field, so any offset/width
      4 // bug yields a wrong sum.
      5 //
      6 // b.a=3; b.b=5; b.c=7; return (b.a + b.b*10 + b.c*100) == 753; -> 1.
      7 
      8 int main() {
      9     struct B { unsigned char a; unsigned char b; unsigned char c; };
     10     struct B b;
     11     b.a = 3;
     12     b.b = 5;
     13     b.c = 7;
     14     return (b.a + b.b * 10 + b.c * 100) == 753;
     15 }