Solved

What 's different between two type aligns...

Posted on 2004-08-11
3
187 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

773 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