mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.37k stars 305 forks source link

Modules inside cfg_if! macros aren't read / expanded (was: The C header file cannot be generated correctly.) #935

Open ssrlive opened 6 months ago

ssrlive commented 6 months ago

The c header file cannot be generated correctly. This is my project. I entered the project root directory and entered the command cbindgen -l c, and got the following output. I did not see the expected function prototype socks_hub_run and so on.

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

image

ssrlive commented 6 months ago

emm, I have found the reason, it's about cfg_if::cfg_if! macro. when I remove it, cbindgen works fine.

can you fix it as a bug?

image

emilio commented 6 months ago

There's the cargo expand feature that should work, right?

luodongseu commented 1 week ago

mark