Add #[repr(C)] for enums
adamski opened this issue · comments
I'm writing a Rust library that exposes a C API. We are defining a custom error type using this library (thank you!). I would like to be able to expose the enum to the C API, and have it be picked up by cbindgen
. Looking at the syntax for adding e.g. #[derive(PartialEq)]
I tried adding #[repr(C)]
but it does not work as I hoped!
E.g.
custom_error!{
#[repr(C)]
MyError
A="error a",
B="error b"
}
I assume there are two issues here:
- Support
#[repr(C)]
for enums/structs (which may already be the case?) - Allow
cbindgen
to pick it up. I believe)cbindgen
scans the source, and I'm not sure if it sees expanded macros or not.
Hello! custom_error already supports annotations. What more can it do?
I am going to close this since this is not actionable. repr(C) is already supported (just like any other annotation). If cbindgen wants to add support for parsing macro calls, they can; but there is nothing we can do inside this library. You may want to use another error handling library that is not based on macro calls.