boot2

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

024-globals.c (497B)


      1 /* tests/cc-e2e/24-globals.c — initialized data + bss + array element + char[].
      2  * Split from 01-kitchen-sink. */
      3 
      4 int g_scalar = 42;
      5 int g_zero;                                /* bss */
      6 int g_arr[3] = { 10, 20, 30 };
      7 char g_msg[] = "hello";
      8 
      9 int test_globals(void) {
     10     g_zero = g_zero + 1;            /* now 1 */
     11     return g_scalar + g_zero + g_arr[1] + g_msg[0];     /* 42+1+20+'h'(104) = 167 */
     12 }
     13 
     14 int main(int argc, char **argv) {
     15     if (test_globals() != 167) return 1;
     16     return 0;
     17 }