Solved

turn off compiler led padding

Posted on 2013-12-20
1
394 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

840 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