How to set breakpoint by function name inside anonymous namespace in Visual Studio?

I have the following code:

namespace { void Foo() { } } namespace Bar { void Foo() { } } int main() { Foo(); Bar::Foo(); return 0; } 

I want to set a breakpoint on Foo() inside an anonymous namespace by name (Ctrl + B key binding). I can do this for a function inside the Bar namespace without a problem named Bar::Foo . I tried anonymous namespace::Foo for an anonymous namespace, but VS was unable to parse that name, I think because of the space character in the name. I also tried putting different quotes, but no luck. Is it even possible to set this breakpoint?

+6
source share
2 answers

I ran into a similar problem a long time ago ( Debugging data in "anynomous namespaces" (C ++) ). I wanted to look at the value of a data member in an unnamed namespace, but I could not do it.

Finally, someone pointed me to http://msdn.microsoft.com/en-us/library/0888kc6a%28VS.80%29.aspx . Perhaps you can get a decorated function name and set a breakpoint on it.

+3
source

It seems like Visual Studio cannot set a breakpoint by function name inside an anonymous namespace. Even WinDbg cannot do this.

If you have sources, you can set a breakpoint on a line.

0
source

Source: https://habr.com/ru/post/897143/


All Articles