C++11の新しいエイリアス宣言を使用した次のコード例はVC++11でのコンパイルに失敗し、VS2012の更新1でエラーが発生します。を使用して、Windows7のMinGWでGCC4.7.2を使用して、のぞき見なしでコンパイルおよび実行しg++ -std=c++11 -Wall in.cpp
ます。
これがサポートされていないという兆候は見つかりませんでした。さらに、IntelliSenseはエラーを検出せず、cdptr
タイプのツールチップを表示しますtypedef const double *cdptr
。私のプロジェクトは、v110プラットフォームツールセットを使用し、C++コードとしてコンパイルするように設定されています。
どうやってマイクロソフトを不当に扱ったのですか?
#include <iostream>
int main()
{
using cdptr = const double*;
const double pi = 3.14159;
cdptr cdp = π
std::cout << "cdp: " << (*cdp) << std::endl;
return 0;
}
ビルド出力:
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 ==========