简体   繁体   English

在natvis文件中使用宏?

[英]Using macros in natvis files?

I just learned about .natvis files in Visual Studio and I've been setting up some for my Ruby C++ Extension project. 我刚刚了解了Visual Studio中的.natvis文件,并且已经为我的Ruby C ++ Extension项目设置了一些文件。 http://msdn.microsoft.com/en-us/library/jj620914.aspx http://msdn.microsoft.com/en-us/library/jj620914.aspx

However, then I tried to use one of the Ruby macro's in a conditional statement then I get errors: 但是,然后我尝试在条件语句中使用Ruby宏之一,然后出现错误:

Natvis: C:\Users\Thomas\Documents\Visual Studio 2013\Visualizers\SUbD.natvis(79,4): Error: identifier "NIL_P" is undefined
    Error while evaluating 'NIL_P(value_)' in the context of type 'SUbD.so!SUbD::ruby::Numeric'.

The rule I'm trying is this: 我正在尝试的规则是这样的:

<Type Name="SUbD::ruby::Numeric">
  <DisplayString Condition="NIL_P(value_)">Ruby Numeric: Nil</DisplayString>
  <DisplayString>Ruby Numeric: {value_}</DisplayString>
</Type>

In my project I am wrapping Ruby's VALUE type in small C++ wrapper classes for common types such as String , Hash , Array etc. And I've been able to set up natvis rules for these. 在我的项目中,我将Ruby的VALUE类型包装在小型C ++包装器类中,以用于常见类型,例如StringHashArray等。而且我已经能够为它们设置natvis规则。 But whenver I want to use some of the macros from the Ruby system I always get errors. 但是,每当我想使用Ruby系统中的某些宏时,总会出错。

Is it not possible to use macros in natvis files? natvis文件中不能使用宏吗?

http://msdn.microsoft.com/en-us/library/jj620914.aspx#BKMK_Expressions_and_formatting http://msdn.microsoft.com/en-us/library/jj620914.aspx#BKMK_Expressions_and_formatting

"Natvis expressions are evaluated in the context of the object being visualized, not the current stack frame." “ Natvis表达式是在可视化对象的上下文中而不是当前堆栈框架中评估的。” The debugger cannot evaluate preprocessor macros, thus is would follow that the visualizer can't either. 调试器无法评估预处理器宏,因此可视化器也不能。 You would need to 'manually' expand the preprocessor macro for the expression. 您需要“手动”扩展表达式的预处理器宏。 For example, if NIL_P is defined as: 例如,如果NIL_P定义为:

#define NIL_P(v) !((VALUE)(v) != Qnil)

Then your natvis DisplayString tag would have to be: 然后,您的natvis DisplayString标记必须为:

<DisplayString Condition="!((VALUE)(value_) != Qnil)">Ruby Numeric: Nil</DisplayString>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM