只是做一个简单的记录。
/// main.cpp
#include <iostream>
template<typename T>
T add(T a, T b) {
return a + b //note here missing the ";"
}
int main()
{
std::cout << "Hello World!\n";
}
在Linux GCC环境中
通过 gcc-5.2.0/bin/g++ main.cpp,直接报错:
main.cpp: In function ‘T add(T, T)’:
main.cpp:7:1: error: expected ‘;’ before ‘}’ token
}
上述的报错是预期的。
在Windows Visual Studio 2019环境中
和 是否enable /permissive (工程属性->C/C++ -> Language -> Conformance mode)有关,如果是一个c++ 工程,会默认enable /permissive; 如果是一个cuda工程中的cpp文件编译,默认是disable /permissive, 这时会直接build pass.

3203

被折叠的 条评论
为什么被折叠?



