next up previous
Next: Level 3 Up: Projects on gcc Intermediate Previous: Level 1


Level 2

Add basic data types: character, integer array and single precision floating point to Level 1. We will now have to introduce declarations of variables to specify their type. Arrays indices start from 0. Implicit type coercion is as is in usual C.

Support of basic types introduces new sets of problems like type layout, type correctness of expressions and implementation of any support routines. Naturally, such support structure must be propagated through the complete compilation chain.

Some examples of the source program are:

  1. main()
    {
        char a;
        int b[10];
        int c;
        float d;
        
        c = 17;
        d = 3.14159;
        b[0] = c;
        b[1] = c * c;
        b[2] = d;
        b[3] = d * d;
        b[4] = b[1] + (b[2] * b[0]);
        a = 'A';
    }
    
  2. main()
    {
        char a;
        int b[10];
        int c;
        float d;
        
        a = 'A';
        c = a + 17;
        d = 3.14159;
        b[0] = a;
        b[1] = a * c;
        b[2] = d;
        b[3] = c * d;
        b[4] = b[1] + (b[2] * b[0]);
    }
    



2006-01-08