BUG: enum's don't work in --device-emulation works without --device-emulation

compile with nvcc --device-emulation -c bug-example.cu and it fails with “[font=“Courier”]error: ‘__N8MyStruct5HELLOE’ was not declared in this scope[/font]”, with nvcc -c bug-example.cu it works.

#include <cuda.h>

struct MyStruct {

    enum HelloWorldEnum { NONE = 0, HELLO = 1 };

};

__global__ void device_main() {

    MyStruct::HelloWorldEnum v = MyStruct::HELLO;

}

int cuda_main() {

    device_main<<< 1, 1 >>>();

    return 0;

}

gatoatigrado@oliver:~/sandbox/.cuda_memcpy> nvcc -V

nvcc: NVIDIA ® Cuda compiler driver

Copyright © 2005-2007 NVIDIA Corporation

Built on Tue_Jun_10_05:42:45_PDT_2008

Cuda compilation tools, release 1.1, V0.2.1221

pretty sure about this, don’t kill me if I’m wrong.

Cheers,

Nicholas

bump
can anyone else verify please?

not able to check for 2 days myself, but are you sure C++ is supported in global functions? I somehow remember that global functions are pure C

I have definitely used operator overloading and other c++ only features in global functions, and the same problem occurs in device functions.

nvcc --device-emulation -c bug.cu --host-compilation ‘C’

Okay, thanks. What exactly does this flag do? It seems to still allow c++ code…

Thanks,
Nicholas