Hi,
Is there any difference b/w global variable and static global variable ? and when each one is used in real time environement ?
Thanks
Kiran
|
Team Leader
|
![]() |
| 23Sep2008,16:00 | #2 |
|
Global variable defined with static keyword has a scope limited to translation unit it is defined in. This variable is not "totally" global (possible to use in other source files), it is visible and usable only in this source file (translation unit, to be exact).
|
|
Go4Expert Member
|
|
| 24Sep2008,06:49 | #3 |
|
Static variables are those which are initilaized and defined inside the main() body. These variables can be re-initialied as per requirement and their value changes. On the other hand Global variables are initilaized and defined before the main() body. If you initilialize and define a varibale gloabally it's value will remain constant, meaning whenever you use this variable in your main() body its value used will be the defined value before the main() body . Hope u got that
|
|
Light Poster
|
|
| 25Sep2008,21:54 | #4 |
|
Quote:
Originally Posted by rsodimbakam Confusing? Code: c
If you have no good reason to allow external linkage, I suggest you explicitly declare global variables to be static. Furthermore, I suggest avoiding global variables unless you have no good alternative. (You may not have a good alternative, especially in embedded systems, given your mention of RTS). |

