使用.natvis文件在Visual Studio 2015中自定义多维数组调试 [英] customize multi-dimension array debugging in visual studio 2015 with .natvis file

查看:175
本文介绍了使用.natvis文件在Visual Studio 2015中自定义多维数组调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用arma Matrix,并且希望在调试过程中查看该值。
因此,我按如下方式添加了一个natvis文件:

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&lt;*&gt;">
    <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.

请稍后再解决这个问题

<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>

顺便说一句,我已将Natvis诊断消息的选项设置为错误,但没有任何反应

By the way, I've turned the Natvis diagnostic messages to "Error" in options but nothing is there in the error list.

感谢您的帮助

推荐答案

强制转换为int为我解决了这个问题:

Casting to int solved this for me:

< Size> $ i == 0?(int)n_rows:(int)n_cols< / Size>

这篇关于使用.natvis文件在Visual Studio 2015中自定义多维数组调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆