typedef s truct config {
//data…
} Config;
Config config;
Thus sizeof(Config) should be good. I had stripped the code too much in my question.
This page won’t let me edit the question due to some permission, so I can’t fix it now.
However, I think the problem might have been that I wasn’t calling SDL_RWclose.
/palmface
Be wary when dumping structs to file and reading them back directly into the struct. What happens if you add a field to the struct? What happens if you change a type in the struct and the alignment of the other fields changes?
When I save a file with my game’s data the first thing I write is an int with a version number. So every time I add a new variable I can code it to set that variable to a default value if an older version of the data file is loaded.
It’s a larger dependency, but Google protobuf is really good at serializing complex structures with default values without requiring explicit versioning.