Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a capability or plans to be able to export a header file from Rust code that C code (or Python, Go, whatever) could reference? I couldn't find anything when searching for it but it seems that it'd be possible since Rust doesn't have a runtime, right?


> Rust doesn't have a runtime, right?

Rust does have a runtime (used for tasks and GC'd types amongst others), the runtime can be disabled and the standard library is being split between "requires runtime" and "does not require runtime" (with as much as possible being moved to the latter).

It's incorrect to say that Rust does not have a runtime, but it's correct to say that runtime-less Rust is very much a first-class concern for the project.

PS: note that C does have a runtime as well, if a very minimal one.


Yes, you can expose C symbols from a Rust library:

  #[no_mangle]
  pub extern fn rustlib_increment(x: i32) -> i32 { x + 1 }
#10350 covers actually printing a .h file from Rust code. https://github.com/rust-lang/rust/issues/10530


Awesome. I think the ability to write a nice .h file, in particular, will really be the killer feature for Rust as "better systems language". Exporting headers and symbols for higher level languages in a format that's universally understood.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: