Ask for help! Build error in VC2005

I have witten kernel codes in CUDA,but after building solution,there is an error which said “can’t generate code for non empty constructors or destructors on device”, I don’t know why this happened and how to solve this problem,thank you very much!

It means what it says. nvcc can handle a few C++ constructs, but only those that can be handled by a preprocessor. It would seem that you have written a few classes for use in device code, which use c++ features that don’t follow those rules. To be safe, you should always assume that nvcc is a C only compiler.

Hey ctdxw !

Although this thread is very old i will shortly lay down my experiences, because i got the same error with the cuda 3.0 toolkit (linux)

I declared to classes-like structs with non-empty constructors, which i set up as global (device) variables.
For the first one - set as global pointer - everything worked fine whitout a complain by nvcc.
device metric_t* globalMetric;

the second one i declarded as variable
device odei_t globalSolver;
at this point i got the mentioned compiler error. Using the non-empty constructors in kernel code seemed to work.
Maybe its because custom code is only executed when a kernel is launched ? In addition i found my constructors not very relyable, cause sometimes strange behaviour occured and i could not clarify if it was somwhere in the code or had something to do with my constructors.

ahmmm ?

has anybody seen the “delete post”-button … sorry