This is fairly typical for templated libraries. The error sequence will usually ultimately trace back to one of the files in your project. It’s impossible to demonstrate that with your example, since you’re not providing the whole error output. And if you look at just that one line of your error output, I agree that you will never discover what the problem is.
This is not unique behavior to CUDA. And the compiler that is generating that error message is quite possibly cl.exe, the compiler that ships with Visual Studio (since that particular line of code is in a host device function, it will be compiled by both the host and device compiler).
Here’s a more complete, possibly “typical” error report that I see using thrust:
/usr/local/cuda/bin/..//include/thrust/iterator/iterator_traits.h(45): error: name followed by "::" must be a class or namespace name
detected during:
instantiation of class "thrust::iterator_traits<T> [with T=int]"
/usr/local/cuda/bin/..//include/thrust/iterator/detail/iterator_traits.inl(60): here
instantiation of class "thrust::iterator_system<Iterator> [with Iterator=int]"
/usr/local/cuda/bin/..//include/thrust/detail/scan.inl(263): here
instantiation of "OutputIterator thrust::inclusive_scan(InputIterator, InputIterator, OutputIterator) [with InputIterator=int, OutputIterator=thrust::detail::normal_iterator<thrust::device_ptr<uint32_t>>]"
t835.cu(139): here
If I simply look at:
/usr/local/cuda/bin/..//include/thrust/iterator/iterator_traits.h(45): error: name followed by "::" must be a class or namespace name
Then that error message doesn’t give me much to go on.
But if I look at the subsequent lines of error output:
detected during:
instantiation of class "thrust::iterator_traits<T> [with T=int]"
/usr/local/cuda/bin/..//include/thrust/iterator/detail/iterator_traits.inl(60): here
instantiation of class "thrust::iterator_system<Iterator> [with Iterator=int]"
/usr/local/cuda/bin/..//include/thrust/detail/scan.inl(263): here
instantiation of "OutputIterator thrust::inclusive_scan(InputIterator, InputIterator, OutputIterator) [with InputIterator=int, OutputIterator=thrust::detail::normal_iterator<thrust::device_ptr<uint32_t>>]"
t835.cu(139): here
Then that error ultimate gets linked back to a line of source code (139) in a file in my project (t835.cu) that ultimately led to that error.
It’s still not trivial to deduce what is going on, but again this is not unique to CUDA. the windows and linux host compilers behave similarly.