2

I tried to write a auxiliary function but i get always this error when i build the program.

:24:7: error: conflicting types for 'AddVector' float AddVector(float a, float b) ^ :19:12: note: previous implicit declaration is here float a = AddVector(b,c);

my kernel:

__kernel void square(
__global float* input,
__global float* output,
const unsigned int count)
{
//...
float b = 2.f;
float c = 4.f;
float a = AddVector(b,c);
}
float AddVector(float a, float b)
{
return a + b;
}

but when i do the same with an integer-typ it works:

__kernel void square(
__global float* input,
__global float* output,
const unsigned int count)
{
//...
int b = 2;
int c = 4;
int a = AddVector(b,c);
}
int AddVector(int a, int b)
{
return a + b;
}

what i am doing wrong?

PS: this kernel is doing nothing - its just for finding the mistake

Chris
  • 63
  • 4

1 Answers1

4

Your problem is that you're declaring the AddVector function after it's being used. Move the declaration above the usage (i.e., above the kernel) and it will compile fine.

To understand more about the "implicit function" bit - see here.

Also, using the Intel offline OpenCL compiler - I see the same warning for both your kernels.

    :9:9: warning: implicit declaration of function 'AddVector' is invalid in C99
Community
  • 1
  • 1
Ani
  • 10,826
  • 3
  • 27
  • 46