Use __CUDA_ARCH__ outside device function

Is the following legal in Cuda ?

#ifdef __CUDA_ARCH__
#define X 1
#define X 0

__device__ __host__ int foo()
    return X;

CUDA documentation says that the host should not use __CUDA_ARCH__. So can we pretend the value is undefined? Also, can we use __CUDA_ARCH__ outsde a __device__ function? Even here in practice, it’s used inside, but the macro is defined outside the __device__ function.