syntaxerror while using visual studio 2010

Hello developers,

I’m fighting with VS 2010. I’m not able to compile my code.
I followed the “getting started guide for windows” and the only thing I changed are the the target device setting in the compiler properties to compute_30,sm_30.
Actually I have two different cu-sourcecode files in my project, one I can compile without any problems but for the other I’m getting the error message: systaxerror ‘<’. Strangely in the beginning I had the problem that ThreadIdx and BlockIdx were undefined, so I included device_launch_parameters.h.
However, I hope someone of you will give me an advice how to overcome this issue.

Here comes my code (is a demosaicing algorithm)

#include "stdafx.h" //includes cuda_runtimes.h &  device_launch_parameters.h. and some otheres

/*-------RG ccd  BGRA output ----------------------------*/
 __global__ void bayerRG(const cv::gpu::DevMem2Db in, cv::gpu::PtrStepb out, const int ImgWidth, const int ImgHeight) 
{
    // Note called for every pair, so x/y are for start of cell so need x+1,Y+1 for right/bottom pair
    // R G
    // G B

    // src
    int x = 2 * ((blockIdx.x*blockDim.x) + threadIdx.x);
    int y = 2 * ((blockIdx.y*blockDim.y) + threadIdx.y);

        // could be faster if it would be copied to shared momery before
    uchar r,g,b;       

    // 'R'
    r = (in.ptr(y)[x]);
    g = (in.ptr(y)[x-1]+in.ptr(y)[x+1]+(in.ptr(y-1)[x]+in.ptr(y+1)[x]))/4;
    b = (in.ptr(y-1)[x-1]+in.ptr(y-1)[x+1]+(in.ptr(y+1)[x-1]+in.ptr(y+1)[x+1]))/4; 
    ((uchar4*)out.ptr(y))[x] = make_uchar4( b,g,r,0xff);

    // 'G' in R
    r = (in.ptr(y)[x]+in.ptr(y)[x+2])/2;
    g = (in.ptr(y)[x+1]);
    b = (in.ptr(y-1)[x+1]+in.ptr(y+1)[x+1])/2;
    ((uchar4*)out.ptr(y))[x+1] = make_uchar4( b,g,r,0xff);

    // 'G' in B
    r = (in.ptr(y)[x]+in.ptr(y+2)[x])/2;
    g = (in.ptr(y+1)[x]);
    b = (in.ptr(y+1)[x-1]+in.ptr(y+1)[x+1])/2;
    ((uchar4*)out.ptr(y+1))[x] = make_uchar4( b,g,r,0xff);

    // 'B'
    r = (in.ptr(y)[x]+in.ptr(y)[x+2]+in.ptr(y+2)[x]+in.ptr(y+2)[x+2])/4;
    g = (in.ptr(y+1)[x]+in.ptr(y+1)[x+2]+in.ptr(y)[x+1]+in.ptr(y+2)[x+1])/4;
    b = (in.ptr(y+1)[x+1]);
    ((uchar4*)out.ptr(y+1))[x+1] = make_uchar4( b,g,r,0xff);   
}

extern "C" bool Cuda_BayerRG2BGR(const DevMem2Db img, DevMem2Db out, int DeviceID = 0, cudaStream_t stream = NULL)
{
    dim3 threads(16,16);   
    dim3 grid((img.cols/2)/(threads.x), (img.rows/2)/(threads.y)); 
        int width = img.cols;
        int height = img.rows;

        if (stream == NULL)
            bayerRG<<<grid,threads>>>(img, out, width, height);
        else
        {
            bayerRG<<<grid, threads, DeviceID, stream>>>(img, out, width, height);   
            cudaThreadSynchronize();
        }
        return true;
}

Thank u in advance
cheers greg

Check your build rules and file name extensions. Your observations suggest that you are trying to compile CUDA code as plain C / C++ code. So CUDA’s predefined variables are undeclared and a syntax error when the kernel invocation is encountered.

Thank you,

indeed I forgot to mark my second file as CUDA C/C++ type in the Properties.

cheers
greg