7.3.2 Differences Between CSS and ANSI C

The design specification for CSS should be the same as ANSI C. However, at the present time, some features have not been implemented, including:

The full functionality of #define pre-processor macros is not supported. At this point, things are either defined or undefined and the #ifdef and #ifndef functions can be used to selectively include or not different parts of code.

The promotion of types in arithmetic expressions is not standard. In CSS, the result of an expression is determined by the left-most (first) value in the expression. Thus, 20 / 3.0 would result in an integer value of 6, whereas 20.0 / 3 gives a real value of 6.6667.

The guarantee that only as much of a logical expression will be evaluated as is necessary is not implemented in CSS. Thus, something like `if((a == NULL) || (a->memb == "whatever"))' will (unfortunately) not work as it would in C, since the second expression will be evaluated even when a is NULL.

Initialization of multiple variables of the same type in the same statement, is not supported, for example:

  int var1 = 20, var2 = 10, var3 = 15;

and initialization of an array must occur after it has been declared (see example below).

There are a limited number of primitive types in CSS, with the others defined in C being equivalent to one of these basic CSS types (see section 7.4.5 Basic Types in CSS). This is because everything in CSS is actually represented by an object, so the storage-level differences between many different C types are irrelevant in the script language.

Pointers in CSS are restricted to point to an object which lies in an array somewhere, or is a single entity. The pointer is "smart", and it is impossible to increment a pointer that points to a single entity, which makes all pointer arithmatic safe:

css> int xxx;
css> int* xp = &xxx;
css> print xp
(Int)* xp --> (Int) xxx = 0
css> xp++;
Cannot modify a NULL or non-array pointer value
>1      xp++;
css> print *(xp +1);
Cannot modify a NULL or non-array pointer value
>1      print *(xp +1);

but it is possible to increment and perform arithmetic on a pointer when it points to an array:

css> int xar[10];
css> xp = xar;
css> xar = {0,1,2,3,4,5,6,7,8,9};
css> print xar
(Int) xar[10] {
0       1       2       3       4       5       6       7       8       9 
}
css> print xp
(Int)* xp --> (Int) xar[10] {
0       1       2       3       4       5       6       7       8       9 
}
css> print *(xp+2);
(Int)  = 2
css> print *(xp+3);
(Int)  = 3
css> xp++;
css> print *(xp+3);
(Int)  = 4
css> print *(xp+9);
Array bounds exceeded
>1      p *(xp+9);
(void) Void
css> print *(xp+8);
(Int)  = 9

The error that occurred when the print *(xp+9) command was issued (after xp already points to xar[1]), illustrates the kind of "smart pointers" that are built into CSS, which prevent crashes by preventing access to the wrong memory areas.