Thread: Esercizi vari C
View Single Post
Old 15th January 2012, 23:06   #51
Caterpillar
Premium Netgamers
 
Caterpillar's Avatar
 
Join Date: Jan 2001
Posts: 14,719
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
  1. 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’
  2. 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
  3. 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

Last edited by Caterpillar; 16th January 2012 at 16:36.
Caterpillar is offline   Reply With Quote