I have created a simple semaphore initialization example for demo purpose:
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <unistd.h>
#include <stdlib.h>
int init_semaphore(int semid, int semnum, int initval)
{
union semun pack;
pack.val = initval;
return semctl(semid,semnum,SETVAL,pack);
}
But I am getting the error:
error: aggregate ‘init_semaphore(int, int, int)::semun pack’ has incomplete type and cannot be defined
I am not able to understand why the compiler is throwing the error. The headers are also included properly.