This chapter is from the book
Derived Types
The C99 derived types (arrays, structs, unions, and pointers) constructed from the built-in data types described in Tables 4.1 and 4.2 are supported. There are a few restrictions on the use of derived types:
- The struct type cannot contain any pointers if the struct or pointer to a struct is used as an argument type to a kernel function. For example, the following use case is invalid:
typedef struct { int x; global float *f; } mystruct_t; kernel void foo(global mystruct_t *p) // error. mystruct_t contains // a pointer { ... }
- The struct type can contain pointers only if the struct or pointer to a struct is used as an argument type to a non-kernel function or declared as a variable inside a kernel or non-kernel function. For example, the following use case is valid:
void my_func(mystruct_t *p) { ... } kernel void foo(global int *p1, global float *p2) { mystruct_t s; s.x = p1[get_global_id(0)]; s.f = p2; my_func(&s); }