Simple C99 Compiler
Log | Files | Refs | README | LICENSE

README (2926B)

      2 Derivations from standard C
      3 ===========================
      4 This compiler is aimed to be being fully compatible with the C99 standard, but
      5 it will have some differences:
      7 - Type qualifiers are accepted but ignored.
      8   -----------------------------------------
     10 Type qualifers make the type system ugly, and their uselessness add
     11 unnecessary complexity to the compiler (and increased compilation time):
     12 	- const: The definition of const is not clear in the standard.
     13 	  If a const value is modified the behaviour is implementation
     14 	  defined. It seems it was defined in order to be able to
     15 	  allocate variables in ROM rather than error detection. This
     16 	  implememtation will not warn about these modifications and
     17 	  the compiler will treat them like normal variables (the standard
     18 	  specifies that a diagnostic message must be printed).
     20 	- volatile: This qualifier was added to the standard
     21 	  to be able to deal with longjmp (local variables that are not
     22 	  volatile have undefined state) and for memory mapped registers
     23 	  or variables whose values are modified asynchronously. This can
     24 	  be achieved with special pragma values though.
     25 	  In the first case, this is non-portable code by definition
     26 	  (depending on the register mapped), so it is better to deal with
     27 	  it using another solution (compiler extensions or direct
     28 	  assembler).
     29 	  In the second case, it generates a lot of problems with modern
     30 	  processors and multithreading, where not holding the value in a
     31 	  register is not good enough (an explicit memory barrier is needed).
     33 	- restrict: This qualifer can only be applied to pointers to
     34 	  mark that the pointed object has no other alias. This qualifer
     35 	  was introduced to be able to fix some performance problems in
     36 	  numerical algorithms, where FORTRAN could achieve a better
     37 	  performance (and in fact even with this specifier FORTRAN has a
     38 	  better performance in this field). Ignoring it doesn't make the
     39 	  compiler non-standard and in almost all applications the performance
     40 	  will be the same.
     42 - Function type names
     43   -------------------
     45 C99 allows you to define type names of function types and write something
     46 like:
     48 int f(int (int));
     50 Accepting function types in typenames (or abstract declarators) makes the
     51 grammar ambiguous because it is impossible to differentiate between:
     53         (int (f))  -> function returning int with one parameter of type f
     54         (int (f))  -> integer variable f
     56 Function type names are stupid, because they are used as an alias
     57 of the function pointer types, but it is stupid that something
     58 like sizeof(int (int)) is not allowed (because here it should be
     59 understood as the size of a function), but f(int (int)) is allowed
     60 because it is understood as a parameter of function pointer type.
     62 This complexity is not needed at all as function pointers fix all these
     63 problems without this complexity (and they are the more usual
     64 way of writing such code).