simple c99 compiler
git clone git://
Log | Files | Refs | README | LICENSE

README (3943B)

      1 Deviations from standard C
      2 ===========================
      3 This compiler aims to be fully compatible with the C99 standard, but
      4 it will have some differences:
      6 - Type qualifiers are accepted but ignored.
      7   -----------------------------------------
      9 Type qualifiers make the type system ugly, and their uselessness adds
     10 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 undefined
     14 	  behaviour. 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, it generates a lot of problems with modern
     26 	  processors and multithreading, when not holding the value in a
     27 	  register is not good enough (an explicit memory barrier is needed).
     28 	  In the second case, this is non-portable code by definition
     29 	  (depending on the register mapped), so it is better to deal with
     30 	  it using another solution (compiler extensions or direct
     31 	  assembly). Since it is needed for the correct behaviour
     32 	  of portable programs that use longjmp, this specifier eventually
     33 	  will be implemented.
     35 	- restrict: This qualifier can only be applied to pointers to
     36 	  mark that the pointed object has no other alias. This qualifier
     37 	  was introduced to be able to fix some performance problems in
     38 	  numerical algorithms, where FORTRAN could achieve a better
     39 	  performance (and in fact even with this specifier FORTRAN has a
     40 	  better performance in this field). Ignoring it doesn't make the
     41 	  compiler non-standard and in almost all applications the performance
     42 	  will be the same.
     44 - Function type names
     45   -------------------
     47 C99 allows you to define type names of function types and write something
     48 like:
     50 int f(int (int));
     52 Accepting function types in type names (or abstract declarators) makes the
     53 grammar ambiguous because it is impossible to differentiate between:
     55         (int (f))  -> function returning int with one parameter of type f
     56         (int (f))  -> integer variable f
     58 If you don't believe me try this code:
     60 int
     61 f(int g())
     62 {
     63 	return g();
     64 }
     66 Function type names are stupid, because they are used as an alias
     67 of the function pointer types, but it is stupid that something
     68 like sizeof(int (int)) is not allowed (because here it should be
     69 understood as the size of a function), but f(int (int)) is allowed
     70 because it is understood as a parameter of function pointer type.
     72 This complexity is not needed at all as function pointers fix all these
     73 problems without this complexity (and they are the more usual
     74 way of writing such code).
     76 - Definition of variables with incomplete type
     77   ---------------------------------------------
     79 C89 allows the definition of variables with incomplete type that
     80 have external linkage and file scope. The type of the variable
     81 is the composition of all the definitions find in the file. The exact
     82 rules are a bit complex (3.7.2) so SCC ignores them at this moment
     83 and it does not allow any definition of variables with incomplete type.
     85 If you don't believe me try this code:
     87 struct foo x;
     89 struct foo {
     90 	int i;
     91 };
     93 - Variadic function alike macros
     94   ------------------------------
     96 The standard (C99 6.10.3 c 4) forces to pass more parameters than
     97 the number of parameters present in the variadic argument list
     98 (excluding ...). Scc accepts a parameter list with the same number
     99 of arguments.
    101 #define P(a, ...) a
    103 P(1)