-1

This is the situation as I'm seeing it in my watch-window:

Watch-window output

I'd like to see only the string "AutoOutput", not the pointer value (in case I need it, I might always disable the corresponding natvis entry).

What is the corresponding natvis entry?

I already tried the following ones:

  <Type Name="wchar_t">
  <Type Name="wchar_t[256]">
  <Type Name="wchar_t[]">
  <Type Name="wchar_t*">
  <Type Name="TCHAR">
  <Type Name="TCHAR[]">

but none of them work.

This is how the whole thing is defined:

     TCHAR    m_sz...Name[256]{};
...
typedef WCHAR TCHAR, *PTCHAR;

My idea is to simply add the following entry in the natvis file:

<Type Name="...">
  <DisplayString>"{{value}}"</DisplayString>  <!-- Shows the string content -->
</Type>  

Does anybody know the type name I need to use for this?

1 Answer 1

4

The type name would be char* or wchar_t*. However, you cannot write a Natvis visualizer for primitive types. As noted under limitations:

Natvis doesn't support visualizers for primitive types (for example, int, bool) or for pointers to primitive types.

The best you can do here is to use a format specifier in the watch window, either ,s or ,su depending on whether TCHAR expands to CHAR or WCHAR, respectively, for your build configuration. These format specifiers will inhibit the display of a memory address.


A potential alternative would be to wrap the respective character array in a custom type, e.g.:

struct Name {
    WCHAR m_sz[256];
};

With that, you could author a Natvis visualizer for the Name type. Obviously, do this only if it improves the quality of your code.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.