title: CUDA: Why is it not possible to define static global member functions?
body: <p>When compiling the code below using nvcc (CUDA 5.0), the error "illegal combination of memory qualifiers" appears, as it apparently is impossible to have global kernels in a class. </p>
  
  <pre><code>class A
  {
  public:
      __global__ static void kernel();
  };
  
  __global__ void A::kernel()
  {}
  </code></pre>
  
  <p>I can understand this restriction when dealing with non-static members, but why does the error still occur when the kernel is declared static? The calling of such members would be no different from calling the function when it is declared in a namespace (<code>A</code> in this case).</p>
  
  <pre><code>A::kernel &lt;&lt;&lt; 1, 1 &gt;&gt;&gt; ();
  </code></pre>
  
  <p>Is there a reason I'm missing as to why this hasn't been implemented (yet)?</p>
  
  <p><strong>EDIT:</strong> Based on the responses in both the answers and comments, I haven't been clear enough on my question. My question is not why an error appears. Obviously, this is because it hasn't been implemented. My question is <em>why</em> it hasn't been implemented. So far, I haven't been able to think of a reason that keeps this feature from being implemented. I realize that I might have forgotten about a special case which would complicate matters, hence the question.</p>
  
  <p>The reasons I believe this to be a reasonable feature are:</p>
  
  <ul>
  <li>A static function doesn't have a <code>this</code> pointer So even if the kernel is called on an object that lives on the host, there is no conflict in accessing its data, as this data is inaccessible in the first place (data from what object??).</li>
  <li>You could argue that if the class has static data associated with it, living on the host, this should in principle be accessible from the static kernel. However, static data isn't supported either, so again no conflict.</li>
  <li>Calling a static kernel on an object on the host (<code>A a; a.staticKernel&lt;&lt;&lt;...,...&gt;&gt;&gt;();)</code> would be entirely equivalent to calling it without the object at all (<code>A::staticKernel&lt;&lt;&lt;...,...&gt;&gt;&gt;();</code>), as we are used to in regular C++.</li>
  </ul>
  
  <p>What am I missing?</p>