0
votes

Solved.

I was trying to control the value of a variable in IAR Embedded Workbench (working with STM32F303xC microcontroller). I declared the variables in the library.h files as:

extern int my_variable1;
extern float another_variable //... etc

Then in library.c

int my_variable1 = 15;
float another_variable = 328.47;

In main.c

my_variable1 = 38;
another_variable = pow(10,2) + another_variable/8

But in watch, live watch and quick watch it rises the error : (column 1) Unknown or ambiguous symbol.

I wrote several programs with this IDE and the declaration of static variables worked and it allowed me to see the variable's value using the watches. In other programs i declared the variable as

int my_variable1;

In the main file, outside the main function and it worked too.

How can i solve this error?

As far as we go, it seems the the real question is:

There is a way to show in IAR Embedded Workbench the value of variables shared between .c-s?

2
What is the scope of declare static var into a header?.. - LPs
In that way you can read only the .h and recognize all the variables and the function that this header provides. - EagleOne
There is no reason why you would ever declare variables in header files to begin with. Making a variable "global static" makes even less sense, it is like going to the paint store and asking for "white black" paint. - Lundin
Moreover in this way you could share only the declarations in .h without sharing the .c files (and the source code) - EagleOne
global static is a sort of oxymoron - EagleOne

2 Answers

3
votes

The IDE Embedded Workbench, as form of optimization, doesn't allocate the variables that are declared but not used. So those variables cannot be showed in the watches.

1
votes

The problem is that you declare the variable static.

This means you will have a discrete copies of those variable for each file that #include the hedaer file.

I guess that static watch work as far as you are breaking execution inside a specific function files. It will show you the local scoped copy of variable.