Error when building OpenCl

Hello,
I am new to OpenCL. I come this error when building the kernel source code:

const char* OpenCLProgram[] = {
"__kernel void OpenCLfunc(
",
" __global float* g_input,
",
" __global float* f,
",
" __global float* g_output,
",
" unsigned int n,
",
" __local float *sdata){
",
" unsigned int i = get_global_id(0);
",
" f[i] = pow(g_input[i],2);
",
" barrier(CLK_LOCAL_MEM_FENCE);
",
" unsigned int tid = get_local_id(0);
",
" sdata[tid] = (i < n) ? f[i] : 0;
",
" barrier(CLK_LOCAL_MEM_FENCE);
",
" for(unsigned int s=get_local_size(0)/2; s>0; s>>=1)
",
" {
",
" if (tid < s) sdata[tid] += sdata[tid + s];
",
" barrier(CLK_LOCAL_MEM_FENCE);
",
" }
",
" if (tid == 0) g_odata[get_group_id(0)] = sdata[0];
",
"}
",
};

I want to compute the squared value of an array and then use reduction to compute the sum of array. I have the error message:
Err when building program -11
Build info err 0
<program source>:7:39: error: expected ‘}’
unsigned int i = get_global_id(0);

Any suggestion is appreciated. Thank you.
Regards,
Minhbt

Declare variable “i” as “size_t” instead of “unsigned int”.