How about writing c inside rust macro

I ve got this idea since i saw that slint crate has already implemented a macro that let developers to straightly write slint language in this macro. Also, by the help of extension , let coding in macro can also get language server

it should be technically possible if you write a proc macro that calls into a c to rust transpiler

it would slow down your build times quite a bit tho, and would circumvent most of the safety guarantees of rust.

1 Like

Note, though, that the macro invocation still needs to tokenize properly according to Rust’s rules which AFAIK aren’t the same as C’s. So you’ll need to wrap the C code in something like a string literal within the macro call.

There's crates.io: Rust Package Registry but it's a bit hack IMO. Nice exercise, but I wouldn't use it for serious projects.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.