Skip to content

wchar_t is always replaced with u16 #3029

Answered by pvdrz
ckrenslehner asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ckrenslehner, so I did a quick test with the header you provided

void my_function(wchar_t const * path = nullptr);

and wchar_t is mapped to u32 in my host (x86_64-unknown-linux-gnu) if I run bindgen input.hpp:

/* automatically generated by rust-bindgen 0.70.1 */

extern "C" {
    #[link_name = "\u{1}_Z11my_functionPKw"]
    pub fn my_function(path: *const u32);
}

even though the widestring idea sounds interesting, historically we try to just generate the bindings for the desired target and the recommended approach here is to just generate bindings for each target individually and gate them using cfg!

@ojeda is right, you can only get a typedef for it using C as in C++ it seems to be t…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ckrenslehner
Comment options

Answer selected by ckrenslehner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants