RE: using typedef to create aligned types

Andrew Grant <[email protected]> Wed, 1 Dec 2004 23:53:03 -0000
Newsgroups gmane.games.devel.windows
Message-ID <56C9B4CE640B7044AAF74431F9C963E104ED7635@tankard.brighton.climax.co.uk>
You're changing the alignment, not the size.

Alignment determines where a variable will be allocated in memory, e.g
FredAligned16 will always be allocated on a 16 byte memory boundry but the
size of both types will be the same.


A.
 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On 
> Behalf Of Andras Balogh
> Sent: Wednesday, December 01, 2004 3:46 PM
> To: [email protected]
> Subject: [GD-Windows] using typedef to create aligned types
> 
> MSDN says that I can use typedef to make aligned versions of 
> my types, eg:
> 
> typedef __declspec(align(16)) Fred FredAligned16;
> 
> This works when I declare variables, eg:
> 
> Fred fred1;
> FredAligned16 fred2;	
> 
> fred2 is 16 bytes aligned, while fred1 is not
> 
> But the strange thing is that sizeof(Fred) == 
> sizeof(FredAligned16) is true, even though Fred's size is not 
> a multiple of 16 bytes...
> 
> When I declare different types (ie. not using typedef), then 
> the sizeof will be different because the aligned type will be 
> padded to the next multiple of
> 16 bytes.
> 
> Is this a bug in the compiler??
> 
> 
> 
> Thanks,
> 
> Andras
> 
> 
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide Read honest & 
> candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now. 
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Gamedevlists-windows mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=555
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555