Compiler Problem
-
Hallo Leute!
Ich versuche gerade folgenden Code zu compilen:
http://www.gnu.org/software/libc/manual/html_mono/libc.html#Handler-Returns#include <signal.h> #include <stdio.h> #include <stdlib.h> /* This flag controls termination of the main loop. */ volatile sig_atomic_t keep_going = 1; /* The signal handler just clears the flag and re-enables itself. */ void catch_alarm (int sig) { keep_going = 0; signal (sig, catch_alarm); } void do_stuff (void) { puts ("Doing stuff while waiting for alarm...."); } int main (void) { /* Establish a handler for SIGALRM signals. */ signal (SIGALRM, catch_alarm); /* Set an alarm to go off in a little while. */ alarm (2); /* Check the flag once in a while to see when to quit. */ while (keep_going) do_stuff (); return EXIT_SUCCESS; }
Leider erhalte ich folgende Fehler:
si.c:1:20: error: signal.h: No such file or directory si.c:2:19: error: stdio.h: No such file or directory si.c:3:20: error: stdlib.h: No such file or directory si.c:4:42: error: unistd.h: No such file or directory si.c:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘keep_going’ si.c: In function ‘catch_alarm’: si.c:16: error: ‘keep_going’ undeclared (first use in this function) si.c:16: error: (Each undeclared identifier is reported only once si.c:16: error: for each function it appears in.) si.c: In function ‘main’: si.c:28: error: storage size of ‘handler’ isn’t known si.c:29: error: ‘sigset_t’ undeclared (first use in this function) si.c:29: error: expected ‘;’ before ‘mask’ si.c:31: error: ‘mask’ undeclared (first use in this function) si.c:39: error: ‘SIGALRM’ undeclared (first use in this function) si.c:39: error: ‘NULL’ undeclared (first use in this function) si.c:45: error: ‘keep_going’ undeclared (first use in this function) si.c:50: error: ‘EXIT_SUCCESS’ undeclared (first use in this function)
Als Compiler verwende ich gcc.
Was mach ich falsch?
Danke schonmal!
-
Zeig mal wie du dein Compiler (gcc) aufrufst. Ich seh auf den ersten Blick kein Include-Fehler und er findet ja schonmal die Standard-Includes nicht - das kann normal nicht sein. Welche Distribution verwendest du?
blan
-
gcc si.c rufe ich auf.
also distibution verwende ich linuxmint (ubuntu)
ich hab grad gemerkt dass das problem nichts mit dem code zu tun hat.
komische sache... ich werd mal gcc neu installieren
oder hat sonst noch jemand irgendwelche vorschläge?
-
Schau mal ob es bei dir /usr/include/stdio.h gibt.
blan
-
nein gibts nicht
habs hinbekommen... danke für den tipp