Repository navigation
How to handle unnamed enums? #198
Replies: 3 comments
|
Sounds like an issue with Is there an issue with the enum? What is the expected? |
|
For the first example, I would not expect an extra struct field in the generated FFI. The anonymous enum inside the struct is being used as a named integer constant, not as stored per-instance data. The useful generated shape would be a C# constant near the generated struct, not a field in public const int SteamNetworkingMessagesSessionRequest_k_iCallback = k_iSteamNetworkingMessagesCallbacks + 1;or a nested/static constant if the generator has a convention for constants scoped to a struct. As a workaround before generator support, preprocess or patch the header so those enums have stable names, or convert this specific pattern into constants before it reaches enum SteamNetworkingMessagesSessionRequest_Callback {
SteamNetworkingMessagesSessionRequest_k_iCallback = k_iSteamNetworkingMessagesCallbacks + 1
};The repeated Please mark this answered if the expected generated shape makes sense. |
|
Sounds like the end generated C# code of the structure in question should have a public static field for the constant as suggested above. I would like to see how the struct is used in a C code example to understand how it is used. Why is there a constant that is accessed via the name of enum? Concerns for me at this stage is the constant is computed from another constant. Is that constant available by name somewhere? If not the computed value would need to be materialized when parsing the C abstract syntax tree. From this and understanding how it is used in one or more examples, we can work backwards to collapse the solution space. If changes are needed in either projects from this information then we discuss. |
Uh oh!
There was an error while loading. Please reload this page.
A header I'm looking at a header that contains unnamed enums like:
any advice on how to handle these? the generated ffi excludes them
and in other cases inside the generated .cs file enums come out as:
All reactions