Solved

turn off compiler led padding

Posted on 2013-12-20
1
412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
  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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

624 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