How does one make a wrapper for existing C/C++ code?

27 points Nonetrixwastaken

Since most popular libraries like Vulkan, OpenGL, GTK etc are made for C and by extension C++, you need to adapt the C code to work in Rust take wlgpu or gtk-rs for example.

My question is how is this done? How would you call C code in Rust, or how would you call Rust code in C? It's all x86 assembly in the end but I'm not sure how it's done exactly.

Also what about Firefox? It uses C and C++ but has a small amount of Rust code.