Debugging data in 'anonymous namespaces' (C++)

后端 未结 2 641
眼角桃花
眼角桃花 2020-12-30 06:24

Recently, I got a crash dump file from a customer. I could track the problem down to a class that could contain incorrect data, but I only got a void-pointer to the class,

相关标签:
2条回答
  • 2020-12-30 07:05

    This is mentioned in MSDN. It doesn't look like there's a nice solution within the Watch window (you can get the decorated name of your class from a listing I guess).

    Your "silly-named namespace" idea would work okay, you could also just declare an identical class with a silly name and cast to that type instead.

    0 讨论(0)
  • 2020-12-30 07:25

    Referencing anonymous namespaces in Visual Studio Debugger's expressions is not supported (at least as of VS 2017) and it's really annoying.

    From https://docs.microsoft.com/en-us/visualstudio/debugger/expressions-in-the-debugger#c-expressions

    Anonymous namespaces are not supported. If you have the following code, you cannot add test to the watch window:

    namespace mars
    {   
        namespace  
        {  
            int test = 0;   
        }   
    }   
    int main()   
    {   
        // Adding a watch on test does not work.   
        mars::test++;   
        return 0;   
    }
    
    0 讨论(0)
提交回复
热议问题