Unusal problem with variables in a global structure

G

Gokul

We are facing an unusual problem with variables in a global structure.
These variables are assigned values like mad all over the application.
Agreed, it is a bad design. The application has been running Ok so
far. The problem is, these variables are not assigned properly
anymore.

typedef struct order {
int order_id;
int order_seq;
.
.
.
} ORDER_REC;

After assigning values, the values are shifted to the variables
declared above them. The value of order_seq is seen in order_id and
order_seq remains zero. This is the case with all the other variables.
Move a level up !. Is this a known issue with assigning variables in a
global structure ?

Rgds,
Gokul
 
D

Doug

We are facing an unusual problem with variables in a global structure.
These variables are assigned values like mad all over the application.
Agreed, it is a bad design. The application has been running Ok so
far. The problem is, these variables are not assigned properly
anymore.

typedef struct order {
int order_id;
int order_seq;
.
.
.

} ORDER_REC;

After assigning values, the values are shifted to the variables
declared above them. The value of order_seq is seen in order_id and
order_seq remains zero. This is the case with all the other variables.
Move a level up !. Is this a known issue with assigning variables in a
global structure ?

Hiya,

The only thing I can think of (since you say it's been working until
now) is that maybe the structure definition has changed recently? Is
it possible it's changed and you haven't recomplied *all* the
compilation units that use the structure?

Doug
 
S

santosh

Gokul said:
We are facing an unusual problem with variables in a global structure.
These variables are assigned values like mad all over the application.
Agreed, it is a bad design. The application has been running Ok so
far. The problem is, these variables are not assigned properly
anymore.

typedef struct order {
int order_id;
int order_seq;
.
.
.
} ORDER_REC;

After assigning values, the values are shifted to the variables
declared above them. The value of order_seq is seen in order_id and
order_seq remains zero. This is the case with all the other variables.
Move a level up !. Is this a known issue with assigning variables in a
global structure ?

No, there are no such issues with C itself, it's most likely a flaw in your
application somewhere.

How exactly is the structure written to? Are all members of the structure of
the same type? Is your application a multi-threaded one?

We really can't say more without some more details and/or code.
 
G

Gokul

No, there are no such issues with C itself, it's most likely a flaw in your
application somewhere.

How exactly is the structure written to? Are all members of the structure of
the same type? Is your application a multi-threaded one?

We really can't say more without some more details and/or code.- Hide quoted text -

- Show quoted text -

Doug, I have checked that. No problem there.

To try some options, I declared a structure with local scope, did all
processing and just before returning from the function I copied the
local structure data to the global one. It worked fine. But I am
unable to understand why this happens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top