I have some code in C which I am trying to make nicer by adding a little bit of C++.
I have a struct of structs:
struct CltSensor{
float A, B, C;
}
struct MafSensor{
float min, max;
}
struct GodStruct {
CltSensor clt;
MafSensor maf;
}
what is great about current GodStruct - I know the exact footprint. I know that the total size is 20 bytes, I know that A lives at offset 0 and min lives at offset 12. This is useful because the whole data structure is persisted as is.
Question: is there a way for me to make CltSensor and MafSensor objects but still persist the GodStruct directly?
I do not mind leaving some gaps - say if there would be a 8 bytes header that's fine. If it matters, I compile in fully static context - there is no heap, everything is allocated on the compile time.
I have a struct of structs:
struct CltSensor{
float A, B, C;
}
struct MafSensor{
float min, max;
}
struct GodStruct {
CltSensor clt;
MafSensor maf;
}
what is great about current GodStruct - I know the exact footprint. I know that the total size is 20 bytes, I know that A lives at offset 0 and min lives at offset 12. This is useful because the whole data structure is persisted as is.
Question: is there a way for me to make CltSensor and MafSensor objects but still persist the GodStruct directly?
I do not mind leaving some gaps - say if there would be a 8 bytes header that's fine. If it matters, I compile in fully static context - there is no heap, everything is allocated on the compile time.