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.
Fe see this array definition
int a[] = { 1,2 };
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:
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.