Compiling differences?

Matias Bordese bordese@hal.famaf.unc.edu.ar
Wed May 12 22:25:00 GMT 2004


I was using the setitimer function (libc 2.2.4) and according to the 
options I compile with (with gcc 2.96), I got different behaviors 
(besides, the binaries differ too):

gcc -o timer -Wall -ansi -pedantic timers.c
(I get the message: "Alarm clock", and the program finishes)

and

gcc -o timer2 timers.c
(I get the expected behavior)

	Matias

PD.: The file is attached.
PD2.: Sorry for my poor English.
-------------- next part --------------
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <signal.h>

void s_handler (int signum);

int main ()
{
	struct itimerval timer;

	timer.it_value.tv_sec = 2;      /* Timer actual, segundos */
	timer.it_value.tv_usec = 0;     /* Timer actual, microsegundos */

	timer.it_interval.tv_sec = 1;
	timer.it_interval.tv_usec = 0;

	signal(SIGALRM, s_handler);

	setitimer(ITIMER_REAL, &timer, NULL);

	while(1){

	}

	return 0;

}

void s_handler (int signum)
{
	if (signum==SIGALRM){
		printf("\nPlazo vencido\n");
	}
}





More information about the Gcc-help mailing list