Reputation: 1351
The following code gives me an error:
Node *nodes;
__device__ Node *nodes;
Error: error: variable "nodes" has already been defined
Why can't I have the same name for variables in host and device?
I assume it should be possible since they have different scopes.
Upvotes: 0
Views: 278
Reputation: 72349
I assume it should be possible since they have different scopes.
That is your mistake. They do not have different scopes. They are tagged to exist in different logical CUDA memory spaces, but that does not imply a different scope, as C++ defines it. Both are compiled and emitted as symbols within the same compilation unit, which is why a compiler error is emitted.
Upvotes: 1