structures forward declarations rework#23
Conversation
|
Sorry for for the late reply!
Curious to know more. Do you have a branch where you are doing this work?
I am,not sure why I used In the approach you propose, the type is incomplete, as the actual definition of
Coming back to the proposal, I don't have an objection provided that this change is done across the codebase and doesn't modify the public API (which it doesn't) and compiles on all platforms and langs (which it will). One thing I would really want though, is to separate typedef from fwd declaration, so that you can use Thx! |
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.