microsoft / windows-drivers-rs

Platform that enables Windows driver development in Rust. Developed by Surface.
Apache License 2.0
1.49k stars 65 forks source link

fix: prevent `E0530 function parameters cannot shadow tuple structs` error when using `call_unsafe_wdf_function_binding` #200

Closed wmmc88 closed 1 month ago

wmmc88 commented 1 month ago

E0530 function parameters cannot shadow tuple structs can sometimes be triggered when a new tuple struct is declared with the same name as the parameter name of WDF C function. This C parameter name is used inside the call_unsafe_wdf_function_binding macro, causing the shadowing error.

To fix this, the naming of the function parameters in the macro has been adjusted slightly to use names that are non-standard rust names (snake case post-fixed with a double underscore) in order to lessen the likelihood of a name clash.

side effect: macro usage sites have better syntax highlighting in IDE since the arguments of call_unsafe_wdf_function_binding are now detected as function arguments)