title: I get an error when I try to use printf() in a kernel
body: <p>I'm using Visual Studio 2010 and a GTX480 with compute capability 2.0.</p>
  
  <p>I have tried setting sm to 2.0, but when I attempt to use printf() in a kernel, I get:</p>
  
  <blockquote>
    <p>error : calling a host function("printf") from a __device__/__global__
    function("test") is not allowed</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>#include "util\cuPrintf.cu"
  #include &lt;cuda.h&gt;
  #include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;conio.h&gt;
  #include &lt;cuda_runtime.h&gt;
  
  __global__ void test (void)
  {
    printf("Hello, world from the device!\n");
  }
  
  void main(void)
  {
      test&lt;&lt;&lt;1,1&gt;&gt;&gt;();
      getch();
  }
  </code></pre>
  
  <p>I find a example here: "CUDA_C_Programming_Guide" 'page _106' "B.16.4 Examples"
  at last,it is work for me :D thank you.</p>
  
  <pre><code>#include "stdio.h"
  #include &lt;conio.h&gt;
  
  // printf() is only supported
  // for devices of compute capability 2.0 and higher
  
    #if defined(__CUDA_ARCH__) &amp;&amp; (__CUDA_ARCH__ &lt; 200)
        #define printf(f, ...) ((void)(f, __VA_ARGS__),0)
    #endif
  
  
  __global__ void helloCUDA(float f)
  {
      printf("Hello thread %d, f=%f\n", threadIdx.x, f);
  }
  
  int main()
  {
      helloCUDA&lt;&lt;&lt;1, 5&gt;&gt;&gt;(1.2345f);
      cudaDeviceSynchronize();
      getch();
      return 0;
  }
  </code></pre>