The problem is that &forks is of type
sem_t (*)[5]
That is, a pointer to an array of five sem_t s. A compiler warning is that sd.forks is of type sem_t* , and the two types of pointers are not converted to each other.
To fix this, just change the assignment to
sd.forks = forks;
Due to the interchangeability of the C pointer / array, this code will work as intended. This is because forks will be treated as &forks[0] , which has type sem_t * .
source share