Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

Latest commit

 

History

History
13 lines (8 loc) · 526 Bytes

README.md

File metadata and controls

13 lines (8 loc) · 526 Bytes

About

This is a small example of exporting a C string statically from a C-compatible shared library

The solution is based upon https://stackoverflow.com/questions/33850189/how-to-publish-a-constant-string-in-the-rust-ffi but I feel this is suboptimal.

Run ./build.sh to build.

Problems

  • Cannot use const fn because the feature is unstable
  • *const c_char does not implement Sync which is needed to have something static
  • &[u8].as_ptr() is not a const fn so cannot be used in a static struct initializer