bottlenoselabs / c2cs

Generate C# bindings from a C header.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Macros

lithiumtoast opened this issue · comments

https://github.com/bkaradzic/bgfx/blob/master/include/bgfx/defines.h#L37

This is a show stopper to create bindings for bgfx.

The constants could easily be converted to enums based on analyzing the prefix of macros and checking their value type.

However, the macros with one or more arguments like https://github.com/bkaradzic/bgfx/blob/master/include/bgfx/defines.h#L535 become troublesome...

First intuition is to convert these type of macros to C# static methods with an inline attribute. But what then? The param types can't be known in advance which would be required for a C# static method... What's worse is that there is no guarantee that these macros are actually part of the public C API. This would mean that any and all macros would need to be transpiled to C# regardless if they are or are not part of the public C API...

I think perhaps the problem is macros in general. It's sad that bgfx is using macros.

If anyone has any better idea how to solve I'm all ears.

Solved by other solution: https://github.com/InfectedLibraries/Biohazrd

C2CS will not support function-like macros. Object-like macros could be okay but are not considered right now.