问题描述
下面的代码示例使用别名声明新的C ++ 11无法编译与VC ++ 11,更新1在VS2012并发出包含的错误。它使用 g ++ -std = c ++ 11 -Wall in.cpp
在Windows 7上的MinGW下编译和执行GCC 4.7.2。 b
$ b
我没有找到任何迹象表明这是不支持。此外,IntelliSense不会拾取任何错误,并显示 cdptr
类型的工具提示 typedef const double * cdptr
。我的项目设置为使用v110平台工具集,并编译为C ++代码。
我错了Microsoft?
#include< iostream>
int main()
{
使用cdptr = const double *;
const double pi = 3.14159;
cdptr cdp =& pi;
std :: cout<< cdp:<< (* cdp)
return 0;
}
生成输出:
1> ------构建开始:项目:AliasDeclTest,配置:调试Win32 ------
$即使使用 November CTP ,
1> AliasDeclTest.cpp
1> f:\aliasdecltest\aliasdecltest.cpp(9):错误C2143:语法错误:缺少';'before'='
1> f:\aliasdecltest\ aliasdecltest.cpp(9):错误C2873:'cdptr':符号不能用于声明
1> f:\aliasdecltest\aliasdecltest.cpp(12):error C2065:'cdptr':未声明的标识符
1> f:\aliasdecltest\aliasdecltest.cpp(12):错误C2146:语法错误:在标识符'cdp'之前缺少';'
1> f:\aliasdecltest\ aliasdecltest.cpp(12):error C2065:'cdp':undeclared identifier
1> f:\aliasdecltest\aliasdecltest.cpp(14):error C2065:'cdp':undeclared identifier
= ========= Build:0成功,1失败,0最新,0跳过==========
您可以找到 C ++ 11 支持。
Following code example using alias declaration new in C++11 fails to compile with VC++ 11, update 1 in VS2012 and emits included errors. It compiles and executes without a peep with GCC 4.7.2 under MinGW on Windows 7 using
g++ -std=c++11 -Wall in.cpp
.I didn't find any indications that this isn't supported. Furthermore, IntelliSense doesn't pick up any errors and displays a tooltip for
cdptr
type that saystypedef const double *cdptr
. My project is set to use v110 platform toolset and compile as C++ code.How have I wronged Microsoft?
#include <iostream> int main() { using cdptr = const double*; const double pi = 3.14159; cdptr cdp = π std::cout << "cdp: " << (*cdp) << std::endl; return 0; }
Build output:
1>------ Build started: Project: AliasDeclTest, Configuration: Debug Win32 ------ 1> AliasDeclTest.cpp 1>f:\aliasdecltest\aliasdecltest.cpp(9): error C2143: syntax error : missing ';' before '=' 1>f:\aliasdecltest\aliasdecltest.cpp(9): error C2873: 'cdptr' : symbol cannot be used in a using-declaration 1>f:\aliasdecltest\aliasdecltest.cpp(12): error C2065: 'cdptr' : undeclared identifier 1>f:\aliasdecltest\aliasdecltest.cpp(12): error C2146: syntax error : missing ';' before identifier 'cdp' 1>f:\aliasdecltest\aliasdecltest.cpp(12): error C2065: 'cdp' : undeclared identifier 1>f:\aliasdecltest\aliasdecltest.cpp(14): error C2065: 'cdp' : undeclared identifier ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
解决方案MSVC11, even with the November CTP, does not implement using alias declarations.
You can find a table of C++11 support here.
这篇关于使用别名声明与VC ++ 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!