lassade / c2z

C++ to Zig bindings and transpiler
102 stars 7 forks source link

Handle function parameters that match zig keywords #31

Open Srekel opened 1 month ago

Srekel commented 1 month ago

Upon binding The-Forge, we found a case where it has a function with a parameter called align. This causes a compile error because align is also a Zig keyword. c2z should replace it with @"align".

I believe this is done in one or two other places so hopefully should be a function call that's needed somewhere. :)

Srekel commented 1 month ago

Related, it seems to use @"lol" unnecessarily when generating the pub extern fn lol names. I don't think this was always the case?

lassade commented 4 weeks ago

Yes, this is because, of the no-glue option it avoids generating the c++ glue, but it will be target specific and add use mangled function names these can be something like "?foo@@YAXHD@Z".

the @"" used to be removed during formatting ...

Also I have a function keywordFix that isn't been used, but maybe just decorating names with @"" will be better