您好,最近我安装了 Libtorch,并且可以在我的新 Visual Studio 项目中毫无问题地使用它。目前我正在尝试在现有的 CUDA 项目中使用 Libtorch。但是当我包含 torch 头时,我遇到了这些奇怪的错误,并且我在互联网上找不到有关我的问题的任何解决方案。有谁知道这些错误的原因可能是什么?
Severity Code Description Project File Line Suppression State
Error C2833 'operator {' is not a recognized operator or type DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2059 syntax error: 'newline' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2238 unexpected token(s) preceding ';' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2143 syntax error: missing ';' before 'const' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2833 'operator {' is not a recognized operator or type DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2059 syntax error: 'newline' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2238 unexpected token(s) preceding ';' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2143 syntax error: missing ';' before 'const' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
环境
- Windows 10
- CUDA 10.1
- Visual Studio 2017
- C++14
最佳答案
感谢@john,我意识到另一个库中有一个与 Libtorch 库中的类型名称同名的宏(在我的例子中是一个名为 V 的宏),这就是为什么编译时很困惑。我现在坚持使用这个解决方案。
warning C4003: not enough actual parameters for macro 'max' - Visual Studio 2010 C++
关于c++ - Visual Studio 中的 Libtorch 运算符/语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61029916/