Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kinderjosh/quad-c
Quad C is my own dialect of C written from scratch. It can achieve memory safety through an optional garbage collector, otherwise memory must be manually freed. It currently only targets Linux x86_64.
https://github.com/kinderjosh/quad-c
assembly assembly-language compiler nasm programming-language templeos terry-davis
Last synced: about 1 month ago
JSON representation
Quad C is my own dialect of C written from scratch. It can achieve memory safety through an optional garbage collector, otherwise memory must be manually freed. It currently only targets Linux x86_64.
- Host: GitHub
- URL: https://github.com/kinderjosh/quad-c
- Owner: kinderjosh
- License: bsd-2-clause
- Created: 2025-01-04T22:57:06.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-01-04T23:01:00.000Z (about 1 month ago)
- Last Synced: 2025-01-04T23:26:37.060Z (about 1 month ago)
- Topics: assembly, assembly-language, compiler, nasm, programming-language, templeos, terry-davis
- Language: C++
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Quad C
Quad C is my own dialect of C written from scratch, featuring a custom backend. It can achieve memory safety through an optional garbage collector, otherwise memory must be manually freed. It currently only targets Linux x86_64.
> [!WARNING]
> Quad C is still in development, expect bugs and missing features.## Examples
Hello world:
```c
#import "lib/core.qc"void main() {
puts("Hello world!\n");
}
```Greet the user:
```c
#import "lib/core.qc"void main() {
puts("What is your name? ");
char *name = gets(64); // Returns a malloc'd string, 64 byte capacityputs("Hello, ");
puts(name);
puts("!\n");free(name, 64); // Free all 64 bytes
}
```Optionally, with garbage collection:
```c
#import "lib/core.qc"void main() {
enable_garbage_collection(); // Garbage collector turned on, 16384 byte capacity by defaultputs("What is your name? ");
char *name = gets(64); // Returns a malloc'd string, 64 byte capacityputs("Hello, ");
puts(name);
puts("!\n");// DO NOT FREE OTHERWISE IT WILL FREE TWICE
// the garbage collector does it for youcollect_garbage(); // Garbage collector frees all malloc'd memory
}
```## Installation
### Dependencies
- g++
- make
- nasm```bash
$ git clone https://github.com/kinderjosh/quad-c.git
$ cd quad-c
$ make
```Check it works by compiling and running hello world:
```console
$ ./qcc fun/hello.qc
$ ./a.out
```## Usage
```
usage: ./qcc [options]
options:
-c compile to only an object file
-o place the output into
-S compile to only an assembly file
-S-imports compile to only an assembly file, with imported files included
```## License
[BSD 2-Clause](./LICENSE)