0

I am using visual studio 2022 for daily development, I have binaries that are tied to older libraries or platforms, so I set the platform toolset property to an older version.

But it's not showing the variable values on hover.

enter image description here

enter image description here

It works if modifying the platform toolset to Visual studio 2022(v143).

enter image description here

enter image description here

Could anyone help me to solve this debugging problem? Thanks in advance.

choes
  • 141
  • 1
  • 1
  • 11
  • I reinstalled vs2022 with version 17.2.5, it works now. – choes Feb 03 '23 at 06:57
  • Hi, glad to know you've found the solution to resolve this issue. You can post an answer and [accept your own answer](https://blog.stackoverflow.com/2009/01/accept-your-own-answers/). This will help other users who has the same issue. – Dou Xu-MSFT Feb 03 '23 at 09:17
  • It says _Comment if you're trying to respond to an answer_ while clicking _Answer Your Question_. – choes Feb 03 '23 at 09:39
  • Comment shouldn’t be added for a real solution. Because in this way, people who encounter similar problems will think that this question has no solution when searching. If you do fix this issue, please select [“Yes, I want to post an answer ”](https://i.stack.imgur.com/qEbRF.png) after the prompt to share your solution. And end this question by [accepting the answer](https://stackoverflow.blog/2009/01/06/accept-your-own-answers/) so that people who get similar problems in the future can quickly find a solution. – Dou Xu-MSFT Feb 06 '23 at 02:04
  • You can refer to [this](https://meta.stackoverflow.com/questions/385272/make-it-clearer-that-the-answer-your-question-button-is-not-for-adding-more-in) for detail information. – Dou Xu-MSFT Feb 06 '23 at 02:06
  • I get it, a response is not an answer. It's just a temporary solution, I still don't want to downgrade the version. – choes Feb 07 '23 at 05:40
  • I tested in VS17.4.4 with VS2010 compiler toolset and it shows the variable values on hover in debug mode .Here is the [test result](https://i.stack.imgur.com/beRqh.png).Did you test in new created project and what kind of project type ? Is there any other settings configured? – Dou Xu-MSFT Feb 08 '23 at 07:07
  • Hi ,have you tested in a new created project that type is console app(for example)? and then see if it shows variable values. – Dou Xu-MSFT Feb 14 '23 at 07:37
  • The example in my post is a console app. – choes Feb 16 '23 at 01:50
  • I retested it in my side and guessed the difference in showing string type variable value in debug mode depends on compiler. – Dou Xu-MSFT Feb 20 '23 at 01:43

1 Answers1

0

I tested in VS2022 17.4 with compiler VS2010 and I reproduced the issue. But I find std::string is an type of class in c++.It does return a class type data structure when debugging with old compiler toolset VS2010 in Local window. Expand the str and you will see the value test in _Buf in the char* type data structure. You can add str. c_str() in watch window and you’ll see it shows the value in char* type. c_str returns a const char* that points to a null-terminated string (i.e., a C-style string) enter image description here enter image description here

I guess the reason of the difference in showing string type variable value in debug mode between two compiles is depending on compiler. If you want it to show variable values on hover with VS2010 compiler, here’s a workaround to achieve it.

 const char* str = "test";
 char str[] = "test";
Dou Xu-MSFT
  • 880
  • 1
  • 1
  • 4
  • Thanks for your debugging in this issue. We'll upgrade the toolset to v143, I don't plan to study it in depth. – choes Mar 01 '23 at 01:39