Reputation: 7397
I don't recall being able to add constructors and overloaded operators to structs in plain C. In a book I'm reading it uses both in an example of CUDA C.
If there are any differences between structs in C and CUDA C, what would be a general explanation of them? In the book they use C++ style structs in CUDA C.
Upvotes: 2
Views: 632
Reputation: 46
1) C struct can only contain data member, but CUDA C is more like the C++ style class which can contain functions etc.
2) Only major difference between CUDA struct and CUDA class is that in the former all members are public by default.
Upvotes: 3
Reputation: 8028
CUDA C is really CUDA C++ and relies on a C++ compiler.
From experience nvcc
has trouble compiling actual C code (for the same reason a C++ compiler might).
There once was a --host-compilation
option that switched the compiler from C
to C++
but it never worked. (see here)
Upvotes: 2