Skip to content

Pass const void* to C++ binded function #1049

Open
@haylinmoore

Description

@haylinmoore

Hello,

I'm trying to create Rust bindings for the library for the library https://github.com/richgel999/fpng, I'm trying to bind against their function with a signature of

  bool fpng_encode_image_to_memory(const void* pImage, uint32_t w, uint32_t h, uint32_t num_chans, std::vector<uint8_t>& out_buf, uint32_t flags = 0);

So far I have

        unsafe fn fpng_encode_image_to_memory(pImage: *const i32, width: u32, height: u32, num_chans: u32, out_buf: &CxxVector<u8>, flags: u32) -> bool;

Which according to cxx has the signature of bool (*)(const int*, unsigned int, unsigned int, unsigned int, const std::vector<unsigned char>&, unsigned int) while the intended signature would be bool (*)(const void*, unsigned int, unsigned int, unsigned int, std::vector<unsigned char>&, unsigned int)

How do I inform cxx I would like to pass a void pointer to some data? I tried a lot related to passing [u8]s, but could never get it working

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions