Solved

turn off compiler led padding

Posted on 2013-12-20
1
397 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
IdTCPClient1->Disconnect(); not working 3 86
Outlook 13 84
C++ help/ Toy problem 19 55
Need some help with design 17 21
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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

733 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