473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Struct member alignment (/Zp#) doesn't work

Hi,

I have a project in which i havn't changed the /Zp flag and left it at the
default (8 bytes).
my problem is that upon execution the structs aren't aligned at all, as if i
used /Zp1.
its very problematic when i use another app who send these structs to the
main app, since the sending app sends an aligned message while the main up
reads it analigned i.e. it loses the data.
hope anyone here knows whats the problem and how to fix it.
I use Visual studio 2003 and an unmanaged C++ project.

thanks,
yaniv
Nov 17 '05 #1
1 1074
Yaniv wrote:
Hi,

I have a project in which i havn't changed the /Zp flag and left it
at the default (8 bytes).
my problem is that upon execution the structs aren't aligned at all,
as if i used /Zp1.
its very problematic when i use another app who send these structs to
the main app, since the sending app sends an aligned message while
the main up reads it analigned i.e. it loses the data.
hope anyone here knows whats the problem and how to fix it.
I use Visual studio 2003 and an unmanaged C++ project.


Check the header files you're #including. It's no unheard of for a header
to change the structure packing and leave it changed.

You might adding #pragma pack() after all of your #includes to rule out this
case.

-cd
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: hilmilho | last post by:
Hi you, I'm facing a strange problem, and I don't know what to do. Maybe someone could help me understand this? I'm storing IP and Netmask on the struct below. 1st I store IP an print it, its...
10
by: googler | last post by:
Hello, I have a very simple question that I'm a bit confused about right now. Is it OK to allocate memory by malloc() or calloc() for a struct member and then call free() on it? For example, I have...
1
by: John | last post by:
Hi, What is the struct member aligment of a C# program? Are there any issues with P/Invoke when passing structs to 3rd party C dlls? Thanks
0
by: Harish | last post by:
We have been asked to observe the following in our VC++ coding. I could not completel understand these: 1. Use "long" instead of "int" in structure that are serialized 2. Use #pragma pack(8,...
0
by: Urs Vogel | last post by:
Hi when setting the struct member alignment of a mixed code project to 'default', what is the actual alignment? I need to know since we're creating (struct-) data dynamically and pass it to a...
3
by: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
4
by: myfavdepo | last post by:
Hi friends, i am having some trouble in my prog. with struct member alignment. I have two different static libraries that i use, each with "struct member alignment" set to 8 bytes. In my...
5
by: arnaudk | last post by:
How does one initialize a const struct member of an object? Since it's const, this has to be done in the constructor initialization list. Unfortunately I can't seem to get the syntax right... ...
5
by: petschy | last post by:
Hello All, I confronted recently with the fact that the size of a struct member can't be determined with sizeof(Struct::Member). I'm aware of the alternative methods to do this, however, I'm...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.