What is it ?

My goal was to write the smallest C compiler which is able to compile itself. I choose a subset of C which was general enough to write a small C compiler. Then I extended the C subset until I reached the maximum size authorized by the contest: 2048 bytes of C source excluding the ';', '{', '}' and space characters.

In order to have a portable version of OTCC, I made a variant called OTCCELF. It is only a little larger than OTCC, but it generates directly a dynamically linked i386 ELF executable from a C source without relying on any binutils tools! OTCCELF was tested succesfully on i386 Linux and on Sparc Solaris.

'++', '--', and unary '&' can only be used with variable lvalue (left value).

'=' can only be used with variable or '*' (pointer indirection) lvalue.

New 501v1 Mink Guava Balance Silver Women's Sneaker Function calls are supported with standard i386 calling convention. Function pointers are supported with explicit cast. Functions can be used before being declared.

Types: only signed integer ('int') variables and functions can be declared. Variables cannot be initialized in declarations. Only old K&R function declarations are parsed (implicit integer return value and no types on arguments).

New Silver Balance Sneaker 501v1 Women's Mink Guava Any function or variable from the libc can be used because OTCC uses the libc dynamic linker to resolve undefined symbols.

Instructions: blocks ('{' '}') are supported as in C. 'if' and 'else' can be used for tests. The 'while' and 'for' C constructs are supported for loops. 'break' can be used to exit loops. 'return' is used for the return value of a function.

Identifiers are parsed the same way as C. Local variables are handled, but there is no local name space (not a problem if different names are used for local and global variables).

Numbers can be entered in decimal, hexadecimal ('0x' or '0X' prefix), or octal ('0' prefix).

'#define' is supported without function like arguments. No macro recursion is tolerated. Other preprocessor directives are ignored.