Example:
/// cbindgen:prefix-with-name=false
#[repr(C)]
pub enum Result<T> {
Ok(T),
Err(*mut Error), // Error isn't defined, doesn't matter for this case.
}
#[no_mangle]
pub extern "C" fn hello() -> Result<i32> {
todo!()
}
cbindgen.toml:
language = "C"
[enum]
prefix_with_name = true
Output of cbindgen .:
WARN: Can't find Error. This usually means that this type was incompatible or not found.
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef enum Result_i32_Tag {
Result_i32_Ok_i32,
Result_i32_Err_i32,
} Result_i32_Tag;
typedef struct Result_i32 {
Result_i32_Tag tag;
union {
struct {
int32_t ok;
};
struct {
Error *err;
};
};
} Result_i32;
typedef struct Result_i32 I32Result;
I32Result hello(void);
Note that the Result_i32_Tag cases have been prefixed with Result_i32_ despite the inline comment of /// cbindgen:prefix-with-name=false.