We are starting a rather big project that involves parts in different languages. We decided to have a certain part translated at compile-time from a JSON to the necessary C structs (and other structures for the rest of the system parts).
The struct is defined in a .h, and the declaration will be like const static struct MCSCommandOptionsMessage mcs_command_message_list[] = and then list of parameters in the format required.
The question is: should the auto generated file with the struct declaration be a .h, or is it better to have a .c just for this struct? Why?
Both would be possible, declaration in .h or in the only one .c file the has access to the struct. If the struct defines something like an Interface and/or you generate several structs if would be good to have them in a .h file. It would define a contract. If several instances of the struct exist you have to put the struct definition in a .h file.
If you would to express Isolation and emphasize that the struct is private matter you can define it in the .c file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With