Ho studiato i timer POSIX nel paragrafo 9.5.2 del libro GAPIL. Sto facendo delle prove elementari ma ottengo molti errori come potete vedere pił in basso.
Code:
#include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
int main()
{
timer_t numero1;
struct sigevent sigeventStruct;
sigeventStruct.sigev_notify = SIGEV_SIGNAL;
if(timer_create(CLOCK_MONOTONIC, sigeventStruct, numero1) == -1)
{
printf( "Errore: %s\n", strerror( errno ) );
}
return 0;
}
Errori ottenuti
- struct sigevent sigeventStruct genera errori:
- storage size of ‘sigeventStruct’ isn’t known
- unused variable ‘sigeventStruct’ [-Wunused-variable]
- Type 'sigevent' could not be resolved
- unknown type name ‘sigevent’
- sigeventStruct.sigev_notify = SIGEV_SIGNAL genera errori:
- ‘SIGEV_SIGNAL’ undeclared (first use in this function)
- request for member ‘sigev_notify’ in something not a structure or union
- Field 'sigev_notify' could not be resolved
- each undeclared identifier is reported only once for each function it appears in
- if(timer_create(CLOCK_MONOTONIC, sigeventStruct, numero1) == -1) genera errori:
- implicit declaration of function ‘timer_create’ [-Wimplicit-function- declaration]
- ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
- Symbol 'CLOCK_MONOTONIC' could not be resolved
Compilo con
gcc -O0 -g3 -Wall -c -fmessage-length=0 -std=c99 -lrt -MMD -MP -MF
Compilandolo qui dentro da molti meno errori
http://codepad.org/gwFFldXG