csbindgen icon indicating copy to clipboard operation
csbindgen copied to clipboard

Support for macro_rules! generated functions in csbindgen

Open ilinchunjie opened this issue 4 months ago • 2 comments

Problem Description

csbindgen currently cannot recognize functions generated through macro_rules! macros, preventing these functions from being included in the generated C# binding code.

  • Manually written functions with #[unsafe(no_mangle)] attributes are correctly recognized and generated
  • Functions generated through macro_rules! macros (even with the same attributes) cannot be recognized
  • Generated C# binding files are missing numerous functions generated by macros

Environment Information

csbindgen version: 1.9.5 Rust version: 2024 edition

ilinchunjie avatar Aug 22 '25 02:08 ilinchunjie

Since it's based on AST analysis, I think it would be difficult to process macros.

neuecc avatar Aug 22 '25 03:08 neuecc

There is the unstable -Zunpretty=expanded which could be used to obtain code with macros already expanded and then csbindgen could analyses that.

cbindgen apparently (used to?) usees that

Skgland avatar Aug 22 '25 06:08 Skgland