Solved

turn off compiler led padding

Posted on 2013-12-20
1
385 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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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.

744 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

8 Experts available now in Live!

Get 1:1 Help Now