问题
I am using arma Matrix and I would like to have a look at the value during debugging. So I add a natvis file as followed:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="arma::Mat<*>">
<DisplayString>{{ Size = {n_rows} x {n_cols} }}</DisplayString>
<Expand>
<Item Name="[size]">n_elem</Item>
<ArrayItems>
<Direction>Backward</Direction>
<Rank>2</Rank>
<Size> $i==0?n_rows:n_cols </Size>
<ValuePointer>mem</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
However, it doesn't work at all.
Sooner I relize the problem may be
<Size> $i==0?n_rows:n_rows </Size>
So I try to replace it with any of the following statements and it works
<size> $i==0?5:8 </Size>
<size> $i==0?n_rows:8 </Size>
<Size> $i==0?5:n_cols</Size>
However, if I try any of the following statements, I get nothing again
<size> $i==0?n_rows:n_cols </Size>
<size> $i==0?n_rows:n_rows </Size>
By the way, I've turned the Natvis diagnostic messages to "Error" in options but nothing is there in the error list.
Thanks for any help
回答1:
Casting to int solved this for me:
<Size> $i==0?(int)n_rows:(int)n_cols </Size>
来源:https://stackoverflow.com/questions/40171957/customize-multi-dimension-array-debugging-in-visual-studio-2015-with-natvis-fil