Jonas Maebe wroteOn 11 Oct 2012, at 15:23,
[1] wrote
> Thanks, I think everything is
clear now. My plan now is to
> respect default padding and write
records in one go to disk. The padding
> value will be written to the
file header so the records can be read back
> one variable at a time
when padding differs, otherwise they will be read
> back in one go
again. This will sure come at a cost, but only if the
> file is shared
between different ABI's (as is the case when sharing
> between
different endianess). The result will be that the data
> structures
will be at default padding internally allways making optimal
> use of
the CPU.
>
> So is there a way to get the padding value at
runtime?
No. You really should write the fields one by one. Yes,
it's slower. That's the cost of portability. You can always optimize by first writing them to a buffer and then writing the buffer in one go.
Jonas
Sorry I keep asking questions, but why write them one by one? If I would store the offset each variable has at the time of writing (only need to do one time per record type), I could easily make the loading work (even if the ABI changes when the file is read back). What makes you prefer writing the variables one by one over once at a time?
Darius
Links:
------
[1]