Use of variables in kernel function using OpenCL

Hello Everyone !
My code is as follows.
******* host code******

//some declarations
cl_mem Curr_domain = NULL;
cl_mem dMobj = NULL;

//created check, AvgBlk of type structure domainBlock

// now creating buffers for above datatypes
dMobj = clCreateBuffer(context, CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR, dCount * sizeof(struct domainBlock), AvgBlk, &ret);
Curr_domain = clCreateBuffer(context, CL_MEM_READ_WRITE, dCount *sizeof(struct domainBlock), check, &ret);
//passed these 2 objects to the kernel

******* kernel code******

__kernel void calculateRms( __global struct domainBlock* dMobj, __global struct domainBlock* Curr_domain )
{
int l = get_global_id(0);
int i=0;
int iType=0;

      for(iType =0; iType<8;iType++)
      {
              if(iType==0)
                {
                          Curr_domain = dMobj;
                }
      }

}
This gives me build failure error!
But if I initialize Curr_domain = dMobj; before the loop it won’t. But I want to do this for 6 more times.
So how can I fix this issue?
I’m using Intel® HD Graphics 4000 for executing this program.

Use code blocks next time to preserve indentation “(code=c) (/code)” with [ ] instead of ( ). Did you mean:

[code=c]
*Curr_domain = *dMobj;


instead of
[code=c]
Curr_domain = dMobj;

Because as it is right now, you’re just setting the pointers equal to eachother. You also need to include the struct definition in the kernel file if you are going to be setting fields, the kernel won’t know what to do otherwise. This compiles fine for me:

[code=c]
struct domainBlock
{
int something;
float an_array[7];
double something_else;
};

__kernel void calculateRms(__global struct domainBlock* dMobj, __global struct domainBlock* Curr_domain )
{
for (int iType = 0; iType < 8; ++iType)
if (iType==0)
*Curr_domain = *dMobj;
}

Thanks cartographer! But it is also not working in my code.