Compiler and stuff for Winc (Winc Is Not C), a programming language based on C. The compiler is based on chibicc.
Here is a basic program which uses the standard library. Save it in a file, for example hello.wc.
import "std.io";
import "std.status";
int main() {
println("Hello, world!");
return SUCCESS;
}
To compile and execute it, run:
wincc --project . hello.wc -o hello
./helloCheck out the examples/ directory if you want to see more examples.
Organize your project however you want, with Makefiles and stuff.
The conventional extension for a Winc file is .wc. Headers are not needed unless you wish to use C code.
All C features implemented by chibicc are currently available.
However, I wont hesitate to remove, replace or modify an existing feature if I need to. C is a base, not a prison.
You can find a list of custom features below.
Even though #include is still available for C headers, modules are a cleaner way to organize the code.
They are evaluated at compile-time and there is no need to split the interface and the implementation in several files. Also there is no need for header guards or #pragma once: a module is never evaluated twice.
In a module, all symbols are private by default. To export a symbol, place pub in front of its definition. This only works with global symbols.
You can crawl directories using .:
import "lib.net.utils.ipv4";
To compile the code, you need to tell the compiler about your project location.
wincc --project pathname # other arguments- Boolean types:
bool, with the keywordstrueandfalse - Unsigned sized types:
u8,u16,u32,u64 - Signed sized types:
s8,s16,s32,s64 - Size types:
usize,ssize
Winc provides a clean syntax for using attributes. To use them, follow the following pattern: [[attr, ...]]. You can also give arguments to attributes using () like you would do in a function call.
Once of Winc's goals is to provide a standard-library which provides more modern structures than the libc. The standard library is divided in two parts:
core: everything incoredoes not require allocators nor filesystems nor tasks management.std: built on top ofcore,stdprovides more structures but relies on an operating system to work.
To install the standard library, run the following commands:
cd libraries
chmod +x install.sh
./install.shIt should be installed in ~/.winc.