Solved

turn off compiler led padding

Posted on 2013-12-20
1
386 Views
Last Modified: 2014-01-08
Hi

if the compiler is adding padding to get the struct members aligned properly at a certain byte boundary, how can i turn this off? My IDE is Visual Studio and I am using C++.

thanks
0
Comment
Question by:LuckyLucks
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 39732152
Open your Project Settings (either right-click on your project in the tree view and select 'Properties...' or press 'ALT+F7'). Then go to "Configuration Properties|C/C++|Code Generation" and set 'Struct Member Alignment' to the desired value. To turn that off, select '1 byte'.

BTW, the command line equivalent is '/Zp[n] pack structs on n-byte boundary', see http://msdn.microsoft.com/en-us/library/windows/desktop/aa367388%28v=vs.85%29.aspx ("/Zp switch"). You could also use

#pragma pack(1)

Open in new window


in your code, seemore at http://msdn.microsoft.com/en-us/library/vstudio/2e70t5y1%28v=vs.100%29.aspx ("pack")
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

896 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

17 Experts available now in Live!

Get 1:1 Help Now