| Crates.io | c3ne |
| lib.rs | c3ne |
| version | 0.2.0 |
| created_at | 2025-10-13 02:27:44.704078+00 |
| updated_at | 2025-10-19 11:49:46.194928+00 |
| description | c3ne is a library that aids in compiling C3 code from within a Rust build script in order to use it alongside Rust code. |
| homepage | |
| repository | https://github.com/TheDreamer123/c3ne |
| max_upload_size | |
| id | 1879928 |
| size | 25,705 |
WARNING: c3ne is very experimental. At the time of writing, only GNU/Linux x64 has been tested, but Windows should, in theory, work. Anything else is even more experimental so expect things to break. Cross-compilation has also not been tested.
c3ne is pronounced as 'citrine'.
Interoperating with other languages is not always easy, which is why crates such as cc-rs exist.
I tried using it to interoperate with C3, but after experimenting for a while, I got nowhere.
After that, I decided to write my own solution that supported C3, and am now releasing it.
Using c3ne is not very difficult, in general, you should follow these steps:
build-dependencies:[build-dependencies]
c3ne = "0.2.0"
# ...
build.rs, and write the following:use c3ne::C3FFI;
fn main() {
C3FFI::new().file("extern/hello.c3").compile("hello");
}
build.rs defined, create extern/hello.c3, and write the following inside:module hello @export;
import std::io;
fn void greet() @extern("greet")
{
io::printn("Hello from C3!");
}
src/main.rs write:unsafe extern "C" {
fn greet();
}
fn main() {
unsafe {
greet();
}
}
Now compile and run the code and you should see "Hello from C3!" printed out to your console!
c3ne provides some more options which may be useful to you depending on your goal, you can view the documentation for the crate to see what is available.
I have also written another crate that may be of use, c3ne-types, which implements some of C3's more messy types, mainly strings.