Re: 4 vs 8 alignment
Re: 4 vs 8 alignment
- Subject: Re: 4 vs 8 alignment
- From: Jens Ayton <email@hidden>
- Date: Wed, 13 Dec 2006 18:54:13 +0100
- Openpgp: id=84FF254B
David Fang:
> Sean McBride:
>>
>> How is __attribute__ more portable than pragma pack? Is it not a GNU
>> extension? I know pragma pack is supported by gcc, CodeWarrior, and
>> Visual Studio.
>
> Hi,
> 'Portable' wasn't the right term. Yes, it is a GNU (and others)
> extension. I meant that it's easier to disable __attribute__(...) where
> it is unsupported by #define-ing it to something empty, whereas #pragma
> may not necessarily be "cancel-able", since they are typically
> compiler-specific. Consider:
>
> // suppose you do detect attribute support in an autoconf-fashion:
> #if HAVE_ATTRIBUTE_FOO
> #define __ATTRIBUTE_FOO__ __attribute__((foo))
> #else
> #define __ATTRIBUTE_FOO__
> // no-effect
> #endif
>
> Then you can use __ATTRIBUTE_FOO__ in your source wherever you'd like,
> without having to wrap its uses in more preprocessor conditionals.
> This can be generalized to support other compiler's attribute formats.
> However, with #pragma, you can't wrap around it with a preprocessor macro
> like:
>
> #define __ATTRIBUTE_FOO__ #pragma foo
>
> as '#' has a special meaning to the preprocessor.
...which is precisely why C99 introduced the _Pragma("foo") operator. :-)
--
Jens Ayton
Sed quis custodiet ipsos custodes?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden