• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 4 vs 8 alignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 4 vs 8 alignment


  • Subject: Re: 4 vs 8 alignment
  • From: David Fang <email@hidden>
  • Date: Tue, 12 Dec 2006 23:51:30 -0500 (EST)

> I have a structure thats being read on the PC, that was originally
> packed on the mac side. The struct seems to be 4 byte aligned on the
> Mac, but the struct is 8 byte aligned on the PC ( 172 bytes on the mac
> vs 176 on the pc )
>
> Is there a pragma setting or a setting in xcode that can guarantee the
> data will be packed in 8 byte alignment?

Hi,

You can use attributes with gcc:

__attribute__((aligned))
	aligns to natural machine integer boundary

__attribute__((aligned(8)))
	aligns to user-specified boundary

__attribute__((packed))
	use minimum space

e.g.
struct foo { int x; char y; } __attribute__((aligned));

I prefer __attribute__ over pragma for portability, but otherwise it may
just be a matter of taste.

Fang

 _______________________________________________
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

  • Follow-Ups:
    • Re: 4 vs 8 alignment
      • From: "Sean McBride" <email@hidden>
References: 
 >4 vs 8 alignment (From: "Paul Cummings" <email@hidden>)

  • Prev by Date: Re: ___spin_lock
  • Next by Date: Re: ___spin_lock
  • Previous by thread: Re: 4 vs 8 alignment
  • Next by thread: Re: 4 vs 8 alignment
  • Index(es):
    • Date
    • Thread