1
votes

i'm doing my first step with renderscript, i'm stuck with a basic stuff... How to define a local function and call it in kernel function. I don't need this function to be invokable. it just to make my code more readable by splitting task.

uint8_t RS_KERNEL invert(uint8_t in, uint32_t x, uint32_t y) {
  foo(NULL);
  return in;
}

void foo(char* m){


}

Someone can tell me why this doesn't compile ? Since I found nothing about, maybe it is not possible to use function inside kernel or even not possible to define not invokable function.

( i try function with no argument, with return type and so, but as soon as I want call function inside kernel, compilation failed... )

Thanks for your knowledge.

1

1 Answers

1
votes

I answer to myself with shame :)

-first, if you don't want the function to be invokable, you need to use the static keyword.

-second, Java made me lazy. Of course it could not work, I use the function message() without previous declaration or definition. So you need to put a declaration (or definition) before to use a function. For god sake, this is C not Java :). I can not believe, it took me 2 days to figure it out.

static void foo(char* m){


}

uint8_t RS_KERNEL invert(uint8_t in, uint32_t x, uint32_t y) {
  foo(NULL);
  return in;
}