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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Yaniv said:
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
 
Back
Top