Skip to content

structures forward declarations rework#23

Draft
mxyns wants to merge 1 commit intomsune:masterfrom
mxyns:forward_decls
Draft

structures forward declarations rework#23
mxyns wants to merge 1 commit intomsune:masterfrom
mxyns:forward_decls

Conversation

@mxyns
Copy link
Copy Markdown

@mxyns mxyns commented May 5, 2026

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:

typedef void cdada_list_t;  

Then, the public API exposes cdada_list_t * which is just a sugared void *. 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:

typedef struct cdada_list_t cdada_list_t;

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant