List Info

Thread: RE: Byte Alignment




RE: Byte Alignment
country flaguser name
United States
2007-05-31 21:41:34

Hi Ralph,

> If I have a library that is byte aligned at 1, does anyone have a
> suggestion as to how to use wxWidgets and DialogBlocks?
>
> For now it is on a windows system, but will be moving to include Mac and
> Linux.

Hmm, are you saying you used the compiler option in VC /zp 1 when
compiling? If so, you are not going to have a lot of fun with this.
Basically you will have to wrap all wxWidget's includes with the following:

#pragma push
#pragma pack(4)

#include "wx.h"

#pragma pop

That "should" take care of telling your code that all of wx is
default 4 byte aligned and then return you to your 1 byte alignment. Of
course if you add any includes from your library you need to reverse it:

#pragma push
#pragma pack(1)

#include "blargo.h"

#pragma pop

Please note also that there are some annoying bugs which crop up due
to pack settings which are hard to avoid. I don't know about VC7+ in this
area but previously changing the packing settings caused some very serious
problems for me in the past. Someone had written a library with /zp 1 set
because it made all their code really tiny but even after modifications such
as the above, some code generated improper offsets randomly.

I "hope" I've misunderstood your question here as using /zp 1 is a
really bad thing to be doing in most cases..

KB

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )