Michael
Michael

Reputation: 1498

compilation error with nvcc and BOOST library

nvcc throws

/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

the has_constraints.hpp already has some suspicious code in it:

#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

Question: Is this a nvcc - boost incompatibility, or could there be something wrong with my code?

Upvotes: 0

Views: 1493

Answers (3)

Michael
Michael

Reputation: 1498

What we did at the end was to turn has_constraints_ off as in the example quoted in the question for Sun Studio 11

Upvotes: 0

Anycorn
Anycorn

Reputation: 51565

I have a patch here http://code.google.com/p/asadchev/source/browse/trunk/projects/boost/boost-1.46.0.nvcc.patch

Perhaps you can see what is changed and fix your code likewise

Be aware that the source is seen by both, gcc-like and egg-like compiler parts.

Upvotes: 1

craniumonempty
craniumonempty

Reputation: 3535

Why do you have the "&" before "Model::constraints"? I would think that's the problem. (// it's not apparently)

EDIT:

http://forums.nvidia.com/index.php?showtopic=182890 talk about this issue and have some hack work arounds

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

EDIT2:

Well, after running around this for a while, this is what I'm sticking with:

http://forums.nvidia.com/index.php?showtopic=215470 "There is a known compatibility issue with boost and nvcc. A work around is to split the sources such that you compile the cuda code with nvcc and the boost code with the host compiler." by Justin Luitjens in the Group: NVIDIA Employees

Try it out, but if you can't make it work, compile separately, and then link them.

Upvotes: 1

Related Questions