This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Design question about global variable

Hello

Normall in an application we define global variable as:
int a;
int b;
...

How about use one structure to include all variables, and just define one structure instance? as below:
struct{ int a; int b; ...
}global;

Is the performance slower? does it take more code space? Is there any other drawback?

Thanks.

/Wang

Parents
  • I just want to know is there any drawback, or is any other better ways?

    Withing the existing structure of your program the solution you are proposing could make a lot of sense. Whether that structure is good or bad is a different matter, of course. My guess is that it can be improved.

Reply
  • I just want to know is there any drawback, or is any other better ways?

    Withing the existing structure of your program the solution you are proposing could make a lot of sense. Whether that structure is good or bad is a different matter, of course. My guess is that it can be improved.

Children
No data