In FFI, assume that identifier is a typedef if followed by '*' in parameter list #5733
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug #79576 reports that the error message shown by FFI when parsing a C function declaration which uses typedef's it doesn't know about can be confusing.
For example, given this definition:
Since FFI has not seen a typedef for 'oid', it treats 'oid' as being the name of a parameter. But since it is followed by '*', it fails with this message:
Interestingly, GCC is able to detect that 'oid' is a type name and reports:
Implement a simple workaround: If the identifier in the above case is directly followed by '*', take it as being a typedef. This does not actually allow the parse to succeed, but does make it fail with a more informative message:
Since this fix is quite simplistic, there are probably more complicated cases where it will still not display the most informative error message.
I fully expect that there may be problems with this approach, and am hoping the maintainers can point me in a better direction if necessary.