【发布时间】:2018-04-12 07:32:06
【问题描述】:
我注意到以下代码可以使用 g++/clang++-3.8 编译,但不能使用 nvcc:
#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。
【问题讨论】:
标签: c++11 templates compiler-errors cuda nvcc