structures forward declarations rework#23
Draft
mxyns wants to merge 1 commit intomsune:masterfrom
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello msune,
A while back we tried to generate bindings for pmacct. Since some types of pmacct expose libcdada types, those types were also part of the generated bindings so we can create pmacct structures from other languages. Unfortunately, the way libcdada does forward declarations for its types causes issues with bindings generators.
Atm, from what I understand, libcdada does forward declarations (FD) as follows:
Then, the public API exposes
cdada_list_t *which is just a sugaredvoid *. I am unaware of the reasons the FDs were done like this. If there aren't any specific considerations, I believe it could be rewritten as:That would be, to my knowledge, a more standard way of doing FDs. As an added bonus, this gives stronger type-safety and type checks by forcing the developer to convert pointers explicitly.
I made this draft PR with a POC showing what such changes could look like, applied to lists. It is still rather crude but it compiles and passes the tests ran with
make check. If you are interested in these changes, I could put in a bit of time to do the migration for your other data structures, when possible (I did not look at maps and such yet and don't know the feasability).I know this is quite niche, and the original issue might partly be caused by the way binding generators are implemented. So I would totally understand if you didn't feel the need to address this now or ever.