Hello.
When debugging I cannot see variables in anonymous namespace.
Is it bug or feature?
Best regards,
Valery
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello.
When debugging I cannot see variables in anonymous namespace.
Is it bug or feature?
Best regards,
Valery
Valery,
I did not test this, but unnamed (anonymous) namespace methods and objects can only be seen in the scope of the source file they are in - thus do not seem to be global symbols (I would need to investigate this further to confirm).
In this case, it is possible the debugger will not be able to see them if the program counter is in a place outside of the scope of this file.
Reference:
http://stackoverflow.com/questions/154469/unnamed-anonymous-namespaces-vs-static-functions
Regards,
Rafael
Rafael,
unnamed namespace objects are global symbols, but they are placed in specific namespace.
The name of this namespace is generated by compiler and is invisible for user.
My question is why debugger does not see this namespace.
Best regards,
Valery
No answer,
so I have to insert "static" ~20 times to get my variables visible in debugger.
It's so ugly.
Hi TI, "Beauty will save the world" (Dostoyevsky).
Regards,
Valery.
Hi Valery and Alex,
Could you provide a concrete example ?
I write a simple test case and cannot reproduce the issue.
I test it using both TI ARM and GCC ARM compilers.
I have attached the screen to illistrate what I have observed.
The variables defined in the anonymous namespace are only visible when the PC is at the source file where the variables are defined.
-Raymond
I see.
The issue is with variables declared in anonymous namespace.
I can reproduce what you observe.
I also find that we have processed the variables, however, it is renamed to <unnamed>::c as you can see in the attached screen shot of the module view.
I have filed a bug report SDSCM00048546.
I will fix that in CCS v6.
Regards,
Raymond
For named namespace, you have to prefix the variable with namespace name.
See attached.
As a workaround until this is fixed, you can access variables in the anonymous namespace by prefixing the variable name with ::::
In your example, enter ::::c in the expression view.
You will be able to access the variable.
Regards,
Raymond
Hi Raymond.
As to named namespace, yet another two examples.
-----------
namespace N {
int c = 0;
}
int main(void) {
N::c++;
return 0;
}
----------
namespace N {
int c = 0;
void f() {
c++;
}
}
int main(void) {
N::f();
return 0;
}
----------
In both cases I cannot see the "c" value under cursor.
Regards,
Valery.
For the first case, you have to highlight N::c to see the value of c. see attached.
For the second case, you are right. You should be able to view the value of c when PC is in the function N::f.
I will update the bug to include this case.
Raymond
But all I need to see the field of record is to place cursor over field name, no highlight. The first case is very simillar, isn't it? Debugger can see what I want and does see it in records but doesn't see in namespaces. It's somewhat inconsistently.
Valery.