You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a situation where a C API evolved from using a simple struct FooV1 to a bitfield struct FooV2. This change requires different access patterns for the a field, using direct member access (v1.a) versus a getter method (v2.a()).
#pragma once
typedefstruct {
unsigned chara; // a < 32
} FooV1;
// because a < 32, api owners decided to use 5 bits for a and use rest for new fieldstypedefstruct {
unsigned chara: 5; // a < 32unsigned charb: 3;
} FooV2;
I propose adding a mechanism to force the generation of getter and setter methods for all struct fields, regardless of whether they are bitfields. This would provide consistent access patterns and mitigate breaking changes caused by evolving C APIs using bitfields. For example add bindgen::Builder::force_accessors with regexp support to add structs that need to be generated this way.
If the project uses the library from the system and user uses v1 library it will not be able compile code adopted for v2 library. I want to avoid this because it is not necessarily that such a change is breaking from the point of view of using the C API. (At least, if header and library are the same version)
The text was updated successfully, but these errors were encountered:
I encountered a situation where a C API evolved from using a simple struct
FooV1
to a bitfield structFooV2
. This change requires different access patterns for thea
field, using direct member access (v1.a
) versus a getter method (v2.a()
).I propose adding a mechanism to force the generation of getter and setter methods for all struct fields, regardless of whether they are bitfields. This would provide consistent access patterns and mitigate breaking changes caused by evolving C APIs using bitfields. For example add
bindgen::Builder::force_accessors
with regexp support to add structs that need to be generated this way.If the project uses the library from the system and user uses v1 library it will not be able compile code adopted for v2 library. I want to avoid this because it is not necessarily that such a change is breaking from the point of view of using the C API. (At least, if header and library are the same version)
The text was updated successfully, but these errors were encountered: