B
BobR
struct mystruct {
int var1, var2, var3;
char data[1024 - offsetof(data)];
That's "offsetof( mystruct, data )", of course (as you've
already corrected).
I don't think you can use offsetof on an incomplete type.
As poor Bruce found out.
If you can't find a sane way to do it, think outside the box.
struct dummy{
int var1, var2, var3;
char data[1];
};
struct mystruct{
int var1, var2, var3;
char data[ 1024 - offsetof( dummy, data ) ];
};
// cout<<"sizeof dummy="<<sizeof(dummy)<<std::endl;
// cout<<"sizeof mystruct="<<sizeof(mystruct)<<std::endl;
// sizeof dummy=16
// sizeof mystruct=1024
We'd have to assume (or prey) that the compiler would construct the two
structs the same (up to 'data').
No, it wasn't my bath-water I drank!
<G>