From 43408ef4df909452c7a10992daff911bab97040d Mon Sep 17 00:00:00 2001
From: Leo Tenenbaum
To compile the compiler on a Unix-y system, just run ./build.sh release
. You can supply a compiler by running CC=tcc ./build.sh release
, or build it in debug mode without the release
.
On other systems, you can just compile main.c with a C compiler. toc
uses several C99 and a couple of C11 features, so it might not work on all compilers. But it does compile on quite a few, including clang
, gcc
, and tcc
. It can also be compiled as if it were C++, but it does break the standard in a few places*. So, MSVC can also compile it. The outputted code should be C99-compliant.
On other systems, you can just compile main.c with a C compiler. toc
uses several C99 and a couple of C11 features, so it might not work on all compilers. But it does compile on quite a few, including clang
, gcc
, and tcc
. It can also be compiled as if it were C++, so, MSVC and g++
can also compile it (it does rely on implicit casting of void *
though). The outputted code should be C99-compliant.
toc
compiles to C for three reasons:
toc
compiles to C. Here are some reasons why:
The last three of those could all be removed fairly easily (assuming the system actually has 8-, 16-, 32-, and 64-bit signed and unsigned types).
-And here are all of its C11 features:
If you find a bug, you can report it through GitHub’s issue tracker, or by emailing pommicket@gmail.com.
Just send me the toc
source code which results in the bug, and I’ll try to fix it.
* for those curious, it has to do with goto
. In C, this program:
-int main() {
- goto label;
- int x = 5;
- label:
- return 0;
-}
-
-
-
-Is completely fine. x
will hold an unspecified value after the jump (but it isn’t used so it doesn’t really matter). Apparently, in C++, this is an ill-formed program. This is a bit ridiculous since
-int main() {
- goto label;
- int x; x = 5;
- label:
- return 0;
-}
-
-
-
-is fine. So that’s an interesting little “fun fact”: int x = 5;
isn’t always the same as int x; x = 5;
in C++.