Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Watching Variables with same name in IAR watch window

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hi All,
I need some help, in one project I have started working on, I found that the same name variables (static defined) in separate files, and when I tried to add these variables into the "Live Watch" or "Watch Window", IAR display "Unknown or ambiguous symbol", which is for obvious reasons as it gets confusing which one to display as the same name is used in multiple files.
I searched over the internet and found one page.

And it works fine when the files are in the project directory, if the same name variable is inside some folders, then I am not able to access the variables.
Can anyone please suggest what is the correct format to access these variables?
problem.PNG
 

'Static' designation implies (from my programming experience) that the variable is created inside a function and only exists during that function. The computer keeps track of where it puts those variables separately from global variables.

To eliminate confusion, choose unique names for all variables whether global or static. As soon as you access a same-name variable, set the uniquely-named variable equal to to. Add the unique variable to your Watch window.

It may help to add a few letters to the unique variable name, to remind you what file the variable initially came from, or what function the variable is called from.
 
I agree with you, "static" can also be used for *.c files, making these variables local to that particular module (*.c) file.
I agree that ideally, we should create unique names, but the problem is I started working on a project from between, and there are a lot of these types of variables already in the project, so I don't want to modify all these variables.
I checked the IAR Application note and it's possible to display these variables on the watch window, link shared in my initial post.
The only problem is when the file is inside a folder I am not able to display the variables in the watch window, looks like the problem is related to the usage of correct syntax, which I have to figure out.
 

Another possibility is to find the position (pointer) in memory where the variable is stored. Grab the value directly. Set it to a unique-name variable. Your programming language may or may not have a command which tells you the pointer since it's an advanced function.
 

In the above project, there was a mistake done by me, the filename name is "tes2.c" the "t" is missing, and due to this it was not working.
if I type `tes2\testvar`I am getting the output, so it was my mistake.

But there is some more point, which I got after contacting the IAR support team, and I will share this information below.
If the "pre-include" file is specified in your IAR IDE, then this doesn't work, this is a known issue and is present till now, and they will fix this in the next upcoming releases.

Actually, in my main project, there is a "pre-include" file and that's why even after entering the correct information, I am not getting the proper data on the "Live Watch" or "Watch Window". The example shown here was a demo project to show the issue I am facing.

Now there is another possibility to view/watch the static variables.

Click on `"View" --> "Statics"` this will list down all the status variables in your project and this works well even when the "pre-include" file is included in the IAR IDE.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top