在使用Visual Studio 2005调试时调用函数? [英] invoking functions while debugging with Visual Studio 2005?

查看:455
本文介绍了在使用Visual Studio 2005调试时调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有一些我知道的可能,但我从来没有设法做到。

在VS2005(C + +),在调试时,为了能够从我调试的代码调用一个函数。

当调试复杂的数据结构时,这个功能有时是必要的,而这些结构只能使用观察窗口的正常功能就不容易探究。

这个观察窗口似乎允许写函数调用,但每次我尝试它它给我一个错误或另一个。

Here's something I know is probably possible but I've never managed to do
In VS2005(C++), While debugging, to be able to invoke a function from the code which I'm debugging.
This feature is sometimes essential when debugging complex data structures which can't be explored easily using just the normal capabilities of the watch window.
The watch window seem to allow writing function calls but every time I try it it gives me one error or another.

错误:找不到符号func

错误:参数列表与函数不匹配

错误:成员函数不存在

有没有人成功地使这项工作正常?
我在这里缺少了什么?

Did anyone ever succeed in making this work properly? What am I missing here?

编辑:清楚的是,调用的函数应该是存在于当前范围的符号调试器在。

clearly, the function called should be a symbol that exists in the current scope the debugger is in.

推荐答案

好,这是我发现的

CXX0040意味着 C表达式求值程序不支持涉及构造函数调用的隐式转换。

CXX0047意味着是一个精确的参数匹配或不需要构造对象的匹配。

所以合并意味着如果我想调用一个函数没有一个参数应该有一个隐式转换,没有一个参数需要一个构造。

在这个上下文中的隐式转换似乎包括一些简单的事情,例如转换 'string''const String&'

construction似乎包含了简单的复制构造。所以传递的值不是原始类型的任何东西都会导致错误。

So combined it means that If I want to call a function none of the arguments should have an implicit conversion and none of the arguments should need a construction.
"implicit conversion" in this context seem to include trivial things like converting 'String' to 'const String&'.
"construction" seem to include trivial copy-construction. so passing by value anything that is not a primitive type will result in an error.

所以这基本上使函数只接受原始类型或指针。 strong>

我刚刚测试了这个理论。

So this basically leaves functions that take only primitive types or pointers.
I have just tested this theory successfully.

所以如果你想从观察窗口调用一个方法,添加一个只接收指针和原语的重载,并在watch窗口中适当地传递参数。传递不是基元的对象会传递其地址。

So if you want to be able to call a method from the watch window, add an overload which takes only pointers and primitives and in the watch window pass the arguments appropriately. To pass an object that is not a primitive pass its address.

这篇关于在使用Visual Studio 2005调试时调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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