Cod*_*cks 13 c++ standards-compliance visual-c++ c++11 visual-studio-2012
__func__函数的C++ 11本地预定义变量不能使用默认的内置Visual Studio 2012(v110)编译器或2012年11月的CTP(v120_CTP_Nov2012)编译器在Visual Studio 2012 Professional(安装了Update 1)中进行编译.然而,编辑并没有抱怨任何红色波浪形下划线__func__.__func__在这种情况下foo,它应该给出其包含函数的名称,但这既不编译也不让编辑抱怨:
#include <iostream>
using namespace std;
void foo()
{
cout << __func__ << endl;
return;
}
int main()
{
foo();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它给出了编译器错误:
error C2065: '__func__' : undeclared identifier
Run Code Online (Sandbox Code Playgroud)
我在代码中遗漏了什么,或者在未来的更新中是否可以使用?
con*_*gus 14
MSVC的C99支持总体上很差; 您最好的选择可能是使用MSVC特定的__FUNCTION__宏.有关详细信息,请参阅此问题:跨平台定义宏的_define __FUNCTION__和__func__
更新(2015-06-22):Visual Studio 2015支持__func__,请参阅博客文章
| 归档时间: |
|
| 查看次数: |
14917 次 |
| 最近记录: |