0

I'm looking for a easy way to display a C-style-array in the visual studio watch window without showing its address.

Unfortunately, the format specifier na does only cover pointers.

F.e. see this array definition

int a[] = { 1,2 };

enter image description here

jesses
  • 559
  • 3
  • 15

1 Answers1

1

Maybe it's obvious but an easy workaround the somewhat narrow definition of na is to cast to a pointer. For the example in the question:

enter image description here

The only drawback is that the array length has to be specified manually and that it's way too expressive.

However, what's nice is that this also works with natvis:

<?xml version="1.0" encoding="utf-8"?> 
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> 
  <Type Name="S">
    <DisplayString>a={(int*)a,2na}</DisplayString> 
  </Type>
</AutoVisualizer>

enter image description here

jesses
  • 559
  • 3
  • 15