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

Re: Programming question: sizeof struct?

On 12 Jul 1999, Paul D. Smith wrote:

> The real issue with not being able to have macros expand to #pragma is
> the first point: there is no clean way to use #pragma in a portable
> environment, because you can't use the preprocessor to choose #pragmas
> for different platforms.  All you can do is have massive amounts of
> #ifdefs.

Sure, but almost no compilers use gcc's __attribute__ or anything like it,
so having macros buy you nothing. No matter want, if you want to support
other compilers you are going to either use #pragma pack or some construct
of #ifdefs. Since gcc also supports that pragma thier is very little
reason to ever use __attribute__ in a program designed to run on things
other than gcc. Also in the most common case of simply wanting packed
structures __attribute__ is lots work to implement, so you might as
well use the pragma :>

Their reasons against that pragma existing are valid, but they are not at
all compelling reasons to not use it.


Reply to: