[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Programming question: sizeof struct?



On 9 Jul 1999, Paul D. Smith wrote:

>   jg> I always hated gcc __attribute__, I prefer the simpler and more common
> 
>   jg> #pragma pack(1)
>   jg> struct {};
>   jg> #pragma pack()
> 
> Ugh.  #pragma is terrible.  See the GCC manual for a description of why.

Their two reasons are true but not really compelling. First off, #pragma
pack is virtually a standard, I know of 5 compilers that support the exact
semantics I gave, and secondly you are not going to be using it in a macro
in this context. The big benifit that you do get is that it is done right,
if you miss an alignement directive where you needed one then 'woops'.
 
Sadly every compiler has a gcc-like 'innovation' there are so many
different ways to specify alignement <sigh>

Jason


Reply to: