-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty Opaque structs generated due to forward declaration. #397
Empty Opaque structs generated due to forward declaration. #397
Comments
We have another occurrence of this.
|
I'm not sure if we can solve this without user input about the correct entry-points. Since each entry-point is parsed separately. If an entry-point contains only the forward declaration and is parsed first, ffigen will only generate an empty definition of that struct. However, this works - struct A; // declaration
int sum(struct A a, int b);
struct A{ // definition
int a;
}; since libclang resolves the definition and declaration for us. A possible solution would be to create a header file containing all other header files but if they don't have include-guards the parsing may fail unexpectedly. |
Could we retroactively resolve it ourselves instead of relying on libclang? Or do we have too little information? In other words could we know if its the same struct or don't we know anything and do we risk making 2 different structs one and the same? (That's why we have the automatic renaming in the first place.) For example, if something is opaque, we can always upgrade it to have a definition. However, do we know for sure that that earlier occurrence is not opaque by design but an actual forward declaration?
It probably depends on the code base if there are include guards. (The Dart codebase has them for example.) So, if we add it, it should be a config option. I think if we can't solve it within our code base, this might be a nice solution. Just a one config line fix for projects that have include guards. |
In C, you can make forward declarations like this -
ffigen currently generates
struct A
asOpaque
(without any fields). (This probably also affects enum declarations).Note: This will only happen when parsing this declaration sequentially (i.e if the declaration was included).
The text was updated successfully, but these errors were encountered: