In a C library header I have a struct defined like this:
typedef struct
{
int bar;
} foo;
I would like to change the definition so that the struct is tagged, like this:
typedef struct foo
{
int bar;
} foo;
Does this change the ABI for C++ user of the library? Or even worse, break old sources in some way?
In a C library header I have a struct defined like this:
typedef struct
{
int bar;
} foo;
I would like to change the definition so that the struct is tagged, like this:
typedef struct foo
{
int bar;
} foo;
Does this change the ABI for C++ user of the library? Or even worse, break old sources in some way?
Share Improve this question edited Jan 19 at 12:41 ThePirate42 asked Jan 16 at 20:43 ThePirate42ThePirate42 8926 silver badges24 bronze badges 14 | Show 9 more comments1 Answer
Reset to default -1Updating the struct definition to include a tag does not impact the ABI for C or C++ users of the library. This is because the memory layout, size, and alignment of the struct remain unchanged. Adding a tag is purely a syntactical change, providing a name for the struct without altering its underlying representation or behavior.
struct foo { float potato;} ;
Then this would make a bad situation totally broken. – Avi Berger Commented Jan 16 at 21:18