By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,127 Members | 939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,127 IT Pros & Developers. It's quick & easy.

Struct member alignment problem..

P: n/a
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 application
it has to be 2 bytes and when i terminate the my program i am getting
this error:

DAMAGE: after Normal block (#73) at 0x00323098.
When i changed the alignment to 2 bytes for both
libraries it run and terminated with out any errors. But one of these
static libraries use tibco rendezvous, so when a message is arrived, it
is having some problems with its internal structures and i am not able
to get the message correctly.
is there is something like all the
libraries used in the application should be linked with the same
"struct member alignment"?
can someone help to solve this problem?
thanks
sreehari

Dec 27 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
try offsetof, which is defined in stddef.h. just google it

Dec 27 '06 #2

P: n/a
thanks, but that wont help me here. i tried tracing the program and
found out that inside the tibrv structure the data is wrong.
For example when a msg is received i am individually retrieving each
field in the message (which would include the messge itself). To know
what is the type of field, there is a function named getType. The
function does not return the type as a message, even though it is the
message. This is because the field is storing the data inside a
structure. When the alignment is chnged back to 8 it works fine, but
then again i am getting that heap corruption error..

Dec 27 '06 #3

P: n/a
structure. When the alignment is chnged back to 8 it works fine, but
then again i am getting that heap corruption error..
I would venture a guess and say it has nothing to do with the structure
alignment. All you're doing by changing the structure alignment is exposing
an existing bug in your app that really has its genesis elsewhere in your
program.

I've done the same thing by removing or adding lines of code to an app that
had nothing to do with a particular bug, and mysteriously have the bug
appear and disappear (all the while, the bug was always there, just not
exposed).

So I would suggest *not* fool around with the structure, keep it at 2 bytes,
and fix the bug. Maybe it is the structure alignment -- however you must
make sure this is the problem before tinkering with compiler options.

- Paul
Dec 27 '06 #4

P: n/a
"Paul" <pa**@paul.comwrote in message news:3mzkh.6346$dw6.5177@trndny02...
>structure. When the alignment is chnged back to 8 it works fine, but
then again i am getting that heap corruption error..

I would venture a guess and say it has nothing to do with the structure
alignment. All you're doing by changing the structure alignment is
exposing
an existing bug in your app that really has its genesis elsewhere in your
program.

I've done the same thing by removing or adding lines of code to an app
that
had nothing to do with a particular bug, and mysteriously have the bug
appear and disappear (all the while, the bug was always there, just not
exposed).

So I would suggest *not* fool around with the structure, keep it at 2
bytes,
and fix the bug. Maybe it is the structure alignment -- however you must
make sure this is the problem before tinkering with compiler options.

- Paul
Also, if you're not sure about alignment problems, try a
reinterpret_cast<char*to the address of the returned structure and then
display the data in a console window. At lesat that way you should be able
to figure out the problem.
Dec 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.