Macros for nvcc

I know that [font=“Courier New”]nvcc[/font] defines the [font=“Courier New”]CUDACC[/font] macro to enable files to detect whether they are being compiled with [font=“Courier New”]nvcc[/font] or not. Is there a similar macro which a function can use to detect whether it’s the host or device version. Basically, I have a function which is defined on the host and device, and I’d like to do some error detecting. On the device, all I can do is set an absurd return value, and hope that that breaks something later. On the host, I want to handle the error properly. I’m thinking of something like

[codebox]device host void myFunc( … ) {

if( error ) {









Is there a way to do this, short of having a separate host wrapper which detects the absurd return.