We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I regularly get this when debugging. Optimisations are turned off. Current instance exhibits it perfectly - linked list management where I have just printed some of the local variables and am about to add them to the list. On return from teh fn that adds them to list the list is out of scope. There are quite a lot of local variables (14) because I am trying to track a bug. "not in scope" reported in both watch window and call stack.
e.g. printf("MIL Section [%s] key <%s> val <%s>\r\n", entry.section ? entry.section : "NULL", entry.key, entry.value); if (entry.section) { strcpy(section, entry.section); } AddEntryToList(&mil_list, entry.section, entry.key, entry.value, section);
when on the line if (entry.section) the local var "entry" apparently is out of scope.
Anyone found a way of giving the package (MDK on STM32) a thump - I've tried a complete rebuild and restarting the IDE
The compiler -- even at -O0 -- may have re-arranged allocation of variables or execution of the code from what you expect. If so, setting a breakpoint on 'if ( entry.section ) {' might actually be on code executed before the printf, which could mean that 'entry' isn't visible to the debugger yet.
Have you taken a look at the generated assembly to see whether the breakpoint is where you expect it to be?
The Keil debugger will usually let you set a breakpoint right at the function entry point. That's a good place to observe function arguments.
Well the printf has happened as I see the output - it is purely the variables being out of scope