Unusal problem with variables in a global structure

Discussion in 'C Programming' started by Gokul, Jul 28, 2007.

  1. Gokul

    Gokul Guest

    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
    Gokul, Jul 28, 2007
    #1
    1. Advertising

  2. Gokul

    Doug Guest

    On Jul 28, 11:16 am, Gokul <> wrote:
    > 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
    Doug, Jul 28, 2007
    #2
    1. Advertising

  3. Gokul

    santosh Guest

    Gokul wrote:

    > 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.
    santosh, Jul 28, 2007
    #3
  4. Gokul

    Gokul Guest

    On Jul 28, 3:43 pm, santosh <> wrote:
    > Gokul wrote:
    > > 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.- 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.
    Gokul, Jul 28, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne
    Replies:
    2
    Views:
    467
    Wayne
    Nov 11, 2003
  2. SuperSizeMe
    Replies:
    3
    Views:
    500
    SuperSizeMe
    Jan 14, 2005
  3. jubelbrus
    Replies:
    5
    Views:
    609
    JohnQ
    Jul 20, 2007
  4. Eden Kirin

    SCGIServer and unusal termination

    Eden Kirin, Nov 16, 2009, in forum: Python
    Replies:
    7
    Views:
    394
    Eden Kirin
    Nov 19, 2009
  5. mark4asp
    Replies:
    1
    Views:
    213
Loading...

Share This Page