I am trying to initialize a SIMPLEQ_HEAD in C and I and getting the following error:
# gcc -o semaphore semaphore.c 
semaphore.c: In function `createSemaphore':
semaphore.c:10: syntax error before `{'
My semaphore.c class looks like:
#include <stdio.h>
#include "semaphore.h"
semaphore_t* createSemaphore( int initialCount )
{
    semaphore_t* sem;
    sem = (semaphore_t *) malloc( sizeof( semaphore_t ) );
    sem->head = SIMPLEQ_HEAD_INITIALIZER( sem->head );
    sem->count = initialCount;      // set the semaphores initial count
    return sem;
}
...
int main()
{
    semaphore_t* my_semaphore = createSemaphore( 5 );    
    return 0;
}
And my semaphore.h looks like:
#ifndef SEMAPHORE_H
#define SEMAPHORE_H
#include <sys/queue.h>
#include <pthread.h>
#include <stdlib.h>
struct entry_thread {
    int threadid;
    SIMPLEQ_ENTRY(entry_thread) next;
} *np;
struct semaphore {
    int count;
    pthread_mutex_t mutex;
    pthread_cond_t flag;
    SIMPLEQ_HEAD(queuehead, entry_thread) head;
};
typedef struct semaphore semaphore_t;
semaphore_t* createSemaphore( int initialCount );
void destroySemaphore( semaphore_t* sem );
void down( semaphore_t* sem );
void up( semaphore_t* sem );
#endif
I'm new to C and using SIMPLEQ so if anybody is experienced in this I would greatly appreciate some help.
For your reference, SIMPLEQ_HEAD's man page is: http://www.manualpages.de/OpenBSD/OpenBSD-5.0/man3/SIMPLEQ_HEAD.3.html
