473,419 Members | 1,557 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,419 software developers and data experts.

Struct member alignment problem..

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
4 4640
try offsetof, which is defined in stddef.h. just google it

Dec 27 '06 #2
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Roy Hills | last post by:
When I'm reading from or writing to a network socket, I want to use a struct to represent the structured data, but must use an unsigned char buffer for the call to sendto() or recvfrom(). I have...
67
by: S.Tobias | last post by:
I would like to check if I understand the following excerpt correctly: 6.2.5#26 (Types): All pointers to structure types shall have the same representation and alignment requirements as each...
21
by: hermes_917 | last post by:
I want to use memcpy to copy the contents of one struct to another which is a superset of the original struct (the second struct has extra members at the end). I wrote a small program to test...
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...
4
by: Michael Brennan | last post by:
I have a menu_item structure containing an union. func is used if the menu item should use a callback, and submenu if a popupmen should be shown. struct menu_item { enum { function, popup }...
3
by: Hallvard B Furuseth | last post by:
to find the required alignment of a struct, I've used #include <stddef.h> struct Align_helper { char dummy; struct S align; }; enum { S_alignment = offsetof(struct Align_helper, align) };
11
by: simonp | last post by:
I'm taking an intro course on C++, and our teacher is not being clear on how stuct memory padding is determined. If the memory used by all components defined inside a struct falls between a...
8
by: anon.asdf | last post by:
Hi! OK, lets try "array-copy": { char arrayA; arrayA = (char){1, 2, 3}; } it does *not* work since we're trying to make a fixed array-pointer arrayA, point to another location/address...
6
by: Francois Grieu | last post by:
Hello, I'm asking myself all kind of questions on allocating an array of struct with proper alignment. Is the following code oorrect ? I'm most interested by the statement t =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.