avoid using "C.enum_" expressions in the generated go code#150
avoid using "C.enum_" expressions in the generated go code#150jstrachan wants to merge 1 commit intoxlab:masterfrom
Conversation
if the C header file uses C enums then we can generate go code of the form `C.enum_` which doesn't compile; so using somethign simpler like `uint32` fixes it this workaround works great for me on a project I'm using c-for-go on. I wonder if we need some configuration to enable this behaviour?
|
Can you please provide an example enum that will produce broken code? The enums subject is very tricky as the size is dynamic, if you have enum with |
|
here's a little sample project that demonstrates the issue: if you run which is basically due to this code in the generated func FieldType_ToString(_type C.enum_) string { |
|
I wonder if the issue I'm hitting is more to do with the use of an enum thats not using a |
|
Related discussion #127 (comment) |
|
I'm afraid I can't quite grok how that comment affects a did you mean we need some logic to figure out the size of the enum to determine a more reliable go type than I'm just not sure without something like this patch to get all those use of |
|
The comment I referenced was about how to extract the proper size for enums, so it won't overflow anything. I think that assuming that every enum value can be treated as |
|
@xlab thanks for the clarification! So I'm wondering if we need a configuration option for a strategy on how to pick the right size of the enum given the number of members? I notice that typedef'd enums in the header file seem to be |
if the C header file uses C enums then we can generate go code of the form
C.enum_which doesn't compile; so using something simpler likeuint32fixes itthis workaround works great for me on a project I'm using c-for-go on. I wonder if we need some configuration to enable this behaviour?