__CUDA_ARCH__ in header file

If I do this in a header file:

#if (defined(CUDA_ARCH) && (CUDA_ARCH > 0))
#define ON_CUDA_DEVICE
#else
#define ON_CUDA_HOST
#endif

Then try and use ON_CUDA_DEVICE in a .cu file that includes that header to conditionally compile code for host/device it doesn’t work? I guess because something funky is going on with the two pass compilation?

Is there anyway to get this to work as it’s a little bit more complicated as I have other #define’s in headers triggered off these - where headers are shared with .CPP files etc.

This is with CUDA 7.5 and MSVC2013. I don’t use precompiled headers.

Doh it’s because #pragma message doesn’t output anything when its doing the device pass.

Is there an equivalent of #pragma message that works during the device pass that won’t stop the compilation like a #error will?