Solved

What 's different between two type aligns...

Posted on 2004-08-11
3
168 Views
Last Modified: 2010-04-15
Hi,Experts:
I use MSCV 6.0.
(1)
union Student{
   struct field
   {
      char sex;
      unsigned int age;
      double average;      
   };
   double align;
};
(2)
#pragma pack(push,8)      
struct Student
{
      char sex;
      unsigned int age;
      double average;      
};
#pragma pack(pop)      
(1) and (2) are  aligned on an 8-byte boundary.
Is there any different between them???
Thanks!
0
Comment
Question by:TKD
3 Comments
 
LVL 7

Accepted Solution

by:
aib_42 earned 20 total points
ID: 11788543
As it is, no.
However, the former may have a different alignment on a different platform/implementation.

Try adding a variable of type "__m128i" or "__m128d" or two into the struct. That should pull the alignment up to 16 bytes on a standard MSVC6 configuration.

Then compare the pragma'ed and the normal versions, you should see different alignments, as well as the fact that aligned SSE instructions would not work on the pragma'ed one.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now