Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyx0r/tinycc
Single header C99 compiler (TCC)
https://github.com/kyx0r/tinycc
Last synced: 3 days ago
JSON representation
Single header C99 compiler (TCC)
- Host: GitHub
- URL: https://github.com/kyx0r/tinycc
- Owner: kyx0r
- License: lgpl-2.1
- Created: 2020-02-26T21:43:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-22T23:17:28.000Z (about 3 years ago)
- Last Synced: 2024-08-02T07:01:58.935Z (3 months ago)
- Language: C
- Size: 5.12 MB
- Stars: 26
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tinycc
Single header C99 compiler (TCC)Entire core of TCC compiler in one file. Including all architectures. 52000 LOC
Including my modifications and improvements.
# Why?
It may be painful to deal with complex build systems and files may harm code navigation and/or understanding.
Many people prefer single header libraries, and this is just that, entire compiler is here.# Compiling Tcc
The most simple command will be
For Unix
```
gcc tinycc.c -ldl -lpthread
or bootstrap:
tcc tinycc.c -ldl -lpthread
```For win32
```
gcc tinycc.c
or more explicit, both commands equalent, x86 is default.
gcc tinycc.c -DTCC_TARGET_PE -DTCC_TARGET_I386
```For win64
```
gcc tinycc.c -DTCC_TARGET_PE -DTCC_TARGET_X86_64
```You can add compile defines options youself, look into the file and see what is available or what you need.
# Using Tcc
```cpp
#include /*or on unix*/ #include//This declaration is required to make printf external.
int printf(char *format, ...);//See tinycc.c on how to do argc and argv
int _start()
{
MessageBox(NULL, NULL, "Hello World", 0); //windows only
printf("Hello World\n"); //crt is usable
return 1;
}
```To include CRT on windows link library using -luser32 for example. This will link to a dll using user32.def file in ./lib
For reference refer to tinycc.c file.
```
tcc test.c -luser32
```------------------------------------------------------------------------
# Notes & TODO
Have not tested on Arm, riscv64 but it should work unless i screwed up.- Add intel assembly support (initial parser done)
- Add vector instructions support.