On Jun 29, 2011, at 10:56 AM CDT, Jeff Squyres wrote:

> There's probably an alignment gap between the short and char array, and 
> possibly an alignment gap between the char array and the double array 
> (depending on the value of SHORT_INPUT and your architecture).
> 
> So for your displacements, you should probably actually measure what the 
> displacements are instead of using sizeof(short), for example.
> 
> tVStruct foo;
> aiDispsT5[0] = 0;
> aiDispsT5[0] = ((char*) &(foo.sCapacityFile) - (char*) &foo);

There's a C-standard "offsetof" macro for this calculation.  Using it instead 
of the pointer math above greatly improves readability: 
http://en.wikipedia.org/wiki/Offsetof

So the second line becomes:

----8<----
aiDispsT5[1] = offsetof(tVStruct, sCapacityFile);
----8<----

-Dave


Reply via email to