On 9/16/2012 4:07 PM, Ben Bacarisse wrote:
> [...]
> I agree that there will appear to be no practical advantage if all the
> systems you intend to use support the same #pragma syntax, but I
> consider that just a coincidence. The functional syntax is still better
> even if there is no practical advantage on some particular set of
> implementations.
A problem I haven't seen mentioned is the meaning of the number
in `#pragma pack'. It appears the Microsoft compilers treat the
number as a count of bytes, so 1,2,4 call for alignment to one-, two-,
and four-byte boundaries. I've seen a compiler whose analogous
construct used the number as the count of low-order zero bits in the
addresses, so 1,2,4 meant two-, four-, and sixteen-byte alignment;
for one-, two-, and four-byte alignments you'd specify 0,1,2 as the
number in the #pragma.
Some folks take comfort from the Standard's requirement that
unrecognized #pragmas be ignored, but I don't. The problem remains
that if you write a #pragma for Compiler X, a different Compiler Y
might "recognize" it but attach an entirely different meaning ...
--
Eric Sosman
d
"The speed at which the system fails is usually not important."