にテンプレート友達とコンパイルエラー私は、次のコードは、++ /打ち鳴らす++グラムでコンパイルされることに気づいた - 3.8ではなくNVCCで:CUDA 8.0:名前空間
#include <tuple> // not used, just to make sure that we have c++11
#include <stdio.h>
namespace a {
template<class T>
class X {
friend T;
};
}
私は以下のコンパイルエラーを取得:
/usr/local/cuda-8.0/bin/nvcc -std=c++11 minimum_cuda_test.cu
nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
minimum_cuda_test.cu:7:10: error: ‘T’ in namespace ‘::’ does not name a type
friend T;
興味深いことに、これはNVCCで動作します:
#include <tuple> // not used, just to make sure that we have c++11
#include <stdio.h>
template<class T>
class X {
friend T;
};
これはコンパイラのバグですか?私はnvccが内部的にコンパイラとしてg ++やclangを使うと思っていたので、なぜローカルコンパイラで動作するのか混乱してしまいましたが、nvccでは動作しませんでした。
私はそれがそれを説明することを知っている。サイドノート:CUDA C++のフロントエンドの出力はどうすればわかりますか? –
@MatthiasSpringer: '-v --keep'をnvccに渡すことができます。これはコンパイルプロセスのどこでエラーが発生しているのか、どの入力ファイルが処理されているのかを表示し、入力ファイルを自分で調べます。 – talonmies