title: CUDA Error C2059: syntax error: '<'
body: <p>I have troubles when compiling my code.</p>
  
  <p>First of all, I have to state something:</p>
  
  <ol>
  <li><p>I have no issues to run other simpler CUDA codes in my GTX650Ti GPU. <a href="https://stackoverflow.com/questions/33512284/thrust-exception-thrustsystemsystem-error-at-memory-location-0x00000000">Thrust exception: &quot;thrust::system::system_error at memory location 0x00000000&quot;</a></p></li>
  <li><p>I've been working in a class with several methods and for some unknown reason, this program leads me to the error:
  Error C2059: syntax error: '&lt;'</p></li>
  </ol>
  
  <p>This is part of the code:</p>
  
  <pre><code>__global__ void linearSpaceKernel(double *result, double base, double delta, unsigned int size)
  {
      unsigned int i = blockDim.x * blockIdx.x + threadIdx.x;
      if (i &lt; size)
          result[i] = base + double(i) * delta;
      cudaThreadSynchronize();
  }
  
  void foo::setRange(const double &amp;lower, const double &amp;upper, const unsigned int &amp;samples)
  {
      vector&lt;double&gt; result(samples);
      double dx = (upper - lower) / (samples - 1);
      if (isCUDA)
      {
          device_vector&lt;double&gt; dev_result(samples);
          linearSpaceKernel&lt;&lt;&lt;1, samples&gt;&gt;&gt;(raw_pointer_cast(dev_result.data()), lower, dx, samples);
          thrust::copy(dev_result.begin(), dev_result.end(), result.begin());
      }
      else
      {       
          double summation = lower;
          for (unsigned int i = 0; i &lt; samples; i++)
          {
              result[i] = summation;
              summation += dx;
          }       
      }
      dis = result;
  }
  </code></pre>
  
  <p>I omitted the CUDA error functions and the rest of the code to keep my code short and clear.</p>
  
  <p>I have to clear that <strong><em>setRange</em></strong> is a class member function of <strong><em>foo</em></strong> that calls the kernel <strong><em>linearSpaceVector()</em></strong>. This class provides a Boolean called <strong><em>isCUDA</em></strong> which is used to let the user decide if the execution will be performed in the host or in the device.
  At the end, both execution options update the vector <strong><em>dis</em></strong>, which is a class member vector.</p>
  
  <p>The main function is defined in <strong><em>fooTest.cu</em></strong> as follows:</p>
  
  <pre><code>#include "foo.cuh"
  
  int main()
  {
      CUDAinit();
      foo A;
      A.isCUDA = true;
      A.setRange(0, 1, 100);
      cin.get();
  }
  </code></pre>
  
  <p>The output is the following:</p>
  
  <pre><code>1&gt;------ Build started: Project: fs, Configuration: Debug Win32 ------
  1&gt;  Compiling CUDA source file ..\..\..\..\..\OneDrive\Documentos\Cátedras CONACyT\UTM\Research\FLS\Programs\fsTest.cu...
  1&gt;  
  1&gt;  C:\Users\Arturo\Documents\Visual Studio 2013\Projects\fs\fs&gt;"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include"  -G   --keep-dir Debug -maxrregcount=0  --machine 32 --compile -cudart static  -g   -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\fsTest.cu.obj "C:\Users\Arturo\OneDrive\Documentos\Cátedras CONACyT\UTM\Research\FLS\Programs\fsTest.cu" 
  1&gt;  fsTest.cu
  1&gt;  fs.cu
  1&gt;  c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\detail\error_category.inl(102): warning C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  1&gt;  c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h(168) : see declaration of 'strerror'
  1&gt;  c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\cuda\detail\bulk\detail\pointer_traits.hpp(55): warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning)
  1&gt;  c:\users\arturo\onedrive\documentos\cátedras conacyt\utm\research\fls\programs\fs.cu(332): error C2059: syntax error : '&lt;'
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>And the errors are listed as:</p>
  
  <pre><code>3   Error   C2059: syntax error : '&lt;'   c:\users\arturo\onedrive\documentos\cátedras conacyt\utm\research\fls\programs\fs.cu    332 1   fs
  4   IntelliSense: expected an expression    c:\Users\Arturo\OneDrive\Documentos\Cátedras CONACyT\UTM\Research\FLS\Programs\fs.cu    332 23  fs
  Warning 2   warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning)   c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\cuda\detail\bulk\detail\pointer_traits.hpp    55  1   fs
  Warning 1   warning C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\detail\error_category.inl 102 1   fs
  </code></pre>