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

查看:199
本文介绍了在使用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&'

构造似乎包含微不足道的复制构造。所以通过值,任何不是原始类型的东西都会导致错误。

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.

所以如果你想能够从监视窗口调用一个方法,添加一个只需要指针和原语,而在监视窗口中的重载会适当地传递参数。传递不是原语的对象传递其地址。

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天全站免登陆