The error is generated when a Makefile attempts to compile a .cu (CUDA) file.
We were able to compile this by itself with an .hpp made specifically for it. When we try to get it to compile under an existing header with it’s own a .cpp (in other words .hpp, .cpp plus a .cu), we keep getting this strange compilation error.
For the sake of readability, all the follow messages where prefixed with this directory:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/include/g++-v4/tr1_impl/
Messages:
type_traits(226): error: expected an identifier
type_traits(227): error: expected a ")"
type_traits(227): error: a template argument list is not allowed in a declaration of a primary template
type_traits(229): error: expected an identifier
type_traits(230): error: expected a ")"
type_traits(230): error: a template argument list is not allowed in a declaration of a primary template
type_traits(232): error: expected an identifier
type_traits(233): error: expected a ")"
type_traits(233): error: expected a ">"
type_traits(235): error: expected an identifier
type_traits(236): error: expected a ")"
type_traits(236): error: expected a ">"
type_traits(238): error: expected an identifier
type_traits(239): error: expected a ")"
type_traits(239): error: expected a ">"
type_traits(241): error: expected an identifier
type_traits(242): error: expected a ")"
type_traits(242): error: expected a ">"
type_traits(244): error: expected an identifier
type_traits(245): error: expected a ")"
type_traits(245): error: expected a ">"
type_traits(247): error: expected an identifier
type_traits(248): error: expected a ")"
type_traits(248): error: expected a ">"
Is it possible to have a single .hpp with a .cu and a .cpp behind it?
Yes it is possible, and in fact very common, but if the .hpp includes files that nvcc can’t build, then you can’t include it from the .cu.
You could use
#ifndef __CUDACC__around those files so they don’t get included when compiling the .cu with nvcc.