0

nvcc 抛出

/usr/include/boost/concept/detail/has_constraints.hpp:29: error: ‘&’ cannot appear in a constant-expression
/usr/include/boost/concept/detail/has_constraints.hpp:29: error: template argument 2 is invalid

has_constraints.hpp 中已经有一些可疑代码:

#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x580)
  // Work around the following bogus error in Sun Studio 11, by
  // turning off the has_constraints function entirely:
  //    Error: complex expression not allowed in dependent template
  //    argument expression
  inline no has_constraints_(...);
#else
  template <class Model>
  inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
  inline no has_constraints_(...);
#endif

问题:这是 nvcc boost 不兼容还是我的代码有问题?

4

3 回答 3

1

为什么在“Model::constraints”之前有“&”?我认为这就是问题所在。(// 显然不是)

编辑:

http://forums.nvidia.com/index.php?showtopic=182890讨论这个问题,并有一些破解工作

http://forums.nvidia.com/index.php?showtopic=150025

编辑2:

好吧,在跑了一段时间之后,这就是我坚持的:

http://forums.nvidia.com/index.php?showtopic=215470 “boost 和 nvcc 存在一个已知的兼容性问题。解决方法是拆分源代码,以便您使用 nvcc 和 boost 代码编译 cuda 代码使用主机编译器。” 作者:Justin Luitjens 在集团中:NVIDIA 员工

试试看,但如果你不能让它工作,单独编译,然后链接它们。

于 2011-12-16T16:06:37.127 回答
1

我在这里有一个补丁http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/boost-1.46.0.nvcc.patch

也许您可以看到更改的内容并同样修复您的代码

请注意,类似 gcc 和类似 egg 的编译器部分都可以看到源代码。

于 2011-12-20T09:14:48.053 回答
0

我们最后所做的是关闭 has_constraints_ ,如 Sun Studio 11 问题中引用的示例

于 2012-01-13T11:12:17.740 回答