Hi, I am a new user of Keil C compiler. During debug, I am trying to watch struct data members. But all of them show 0x0000. And they are not updated. With other variables it's just working fine. Any suggestions? Thanks, Titu
Of course, that won't work. When declaring something static, you limit the scope of it to the file in which it is declared (if it's a file scope variable). What you want, is to have access to this item from external files, hence your proposal to make it external. To be able to do that, just don't use the word static when declaring the item in your c-file but instead declare it as external in the header file belonging to that c file. Use that header file in the other c-files where you want to have access to the item. -- Geert
"don't use the word static when declaring the item in your c-file but instead declare it as external in the header file belonging to that c file." Let's get the terminology correct here: "don't use the word static when defining the item in your c-file but declare it as external in the header file belonging to that c file." In other words: The definition needs to be in exactly one .c file - without the 'static' keyword; The 'extern' declaration should be in the header file. Remember: The definition is what actually creates the item - this is what causes memory to be allocated; The declaration merely provides information for other modules that need to access the item - it causes no memory allocation.
Let's get the terminology correct here: "don't use the word static when defining the item in your c-file but declare it as external in the header file belonging to that c file." In other words: The definition needs to be in exactly one .c file - without the 'static' keyword; The 'extern' declaration should be in the header file. You've put it in an more correct context, Andy, which is absolutely OK. But you understood what I was trying to explain, and that's the most important for me! ;-) -- Geert