Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename_types does not appear to work #877

Open
fw-immunant opened this issue Sep 6, 2023 · 1 comment
Open

rename_types does not appear to work #877

fw-immunant opened this issue Sep 6, 2023 · 1 comment

Comments

@fw-immunant
Copy link

This may well be an issue of my understanding, but I've read the documentation and would expect this to result in a memory_map struct rather than MemoryMap:

cbindgen.toml:

language = "C"

[export]
item_types = ["structs", "opaque", "functions"]

[export.mangle]
rename_types = "snake_case"

lib.rs:

#[repr(C)]
pub struct MemoryMap {
    x: u32,
}

#[no_mangle]
pub extern "C" fn memory_map_new() -> Box<MemoryMap> {
    Box::new(MemoryMap {})
}

Cargo.toml:

[package]
name = "cbindgen-test"
version = "0.1.0"
edition = "2021"

Output:

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

typedef struct MemoryMap {
  uint32_t x;
} MemoryMap;

struct MemoryMap *memory_map_new(void);

Am I misunderstanding which types rename_types is supposed to apply to? I know this can be worked around with the export.rename feature, but this seems to be what rename_types should do in general, rather than having to write out each renaming one by one.

@ericdrobinson
Copy link

Possibly related: #763.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants