【发布时间】:2013-09-15 19:12:54
【问题描述】:
我最近更新到 Visual Studio 2012,但在异常规范方面遇到了一些问题。 我不断收到具有表单的系统文件的错误
<some type> function(<some input>) _NOEXCEPT
{
<some code>
}
在哪里
#define _NOEXCEPT throw()
我不太明白为什么会出现错误,因为宏是定义的并且用途是由Visual Studio Exception Handling 定义的。错误类似于:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\list(1119): error C2059: syntax error : '{'
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\list(1119): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
上面“列表”文件的第 1118-1121 行是:
const_iterator begin() const _NOEXCEPT
{ // return iterator for beginning of nonmutable sequence
return (const_iterator(this->_Nextnode(this->_Myhead), this));
}
错误来自“list”和“xtree”,它们都位于上述路径中。 我已经尝试更改上面链接中指定的“\EH”标志,但这没有帮助。
关于什么可能导致这种情况的任何想法?
编辑:添加预处理器文件摘录。
const_iterator begin() const {printf("ERROR: %s\n in file %s at line %d\n", ,"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\include\\list",1118); throw(1);}
{
return (const_iterator(this->_Nextnode(this->_Myhead), this));
}
不确定我应该从这个文件中得到什么,但这里是示例代码。
【问题讨论】:
-
Use C/C++, Preprocessor, Generate Preprocessed File = Yes 看看真正变成了什么。
-
您好,感谢您的回复,我继续创建了预处理器文件。我粘贴了一段我认为会产生错误的代码。我不确定,因为我不知道我在寻找什么。你能告诉我更多吗?
-
嗯,这看起来不像
throw(),是吗?您需要找到能够影响 _NOEXCEPT 宏的#define。右键单击它,转到定义。 -
转到定义:
#define _NOEXCEPT throw ()在其他文件中。我以为大括号的最后一部分没问题,throw()变成了throw(1)
标签: c++ debugging visual-studio-2012 exception-handling