dimanche 24 juillet 2016

Linux gcc <time.h> and threads together

I seem to be in a catch-22. My program uses threads and semaphores so I have included <semaphore.h> but I also want to use struct timespec so I've included <time.h>.

It seems I need to add the compile flag -C99 so my semaphore calls are defined (otherwise I get compile warnings undefined on the likes of sem_post()). But when I define C99, struct timespec is no longer defined!

What defines or compiler flags do I need to set to use struct timespec and functions such as clock_gettime(), define CLOCK_REALTIME, sem_timedwait() along with sem_post(), sem_destroy(), etc?

I haven't got to the link stage yet. This is a compile time error.

Using gcc 4.4.7.

Thanks, Mike

Aucun commentaire:

Enregistrer un commentaire