Michelle
Michelle

Reputation: 611

Error in pointer arithmetic (OpenCL)

Can someone explain me why this code doesn't work?

__kernel void foo(__global const void* a)
{
  __global const uchar* currentPosition = (__global uchar*) a;

  // Update the position
  currentPosition += 4;
}

When I try to read the value of currentPosition after the increment I get the same result as when I don't do the arithmetic.

Why is this happening?

Thank you.

Upvotes: 0

Views: 690

Answers (2)

Michelle
Michelle

Reputation: 611

I found the error yesterday at night. The problem was not with the pointer arithmetic but with data alignment in the buffer a.

Sorry guys but I'm new in OpenCL :(

Upvotes: 0

crdugu
crdugu

Reputation: 11

It's probably the 'const' keyword where you declare currentPosition. C++ does not allow you to modify values. You already set currentPosition when you declare it.

Upvotes: 1

Related Questions