🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2598

proper semi-portable use of signal()?

#2598
From: Guido van Rossum
Date: Tue, 26 Mar 1991 13:15
27 lines
1181 bytes
I have some code that uses signal().  Nothing spectacular, e.g.:

	#include <signal.h>
	...
	void (*sigsave)();
	sigsave = signal(SIGINT, SIG_IGN);
	...
	signal(SIGINT, sigsave);

The compiler that comes closest to Standard C locally (gcc) warns
about this code:

	sigsave = signal(SIGINT, SIG_IGN);
	warning: argument passing between incompatible pointer types

	signal(SIGINT, sigsave);
	warning: assignment between incompatible pointer types

I don't see what's wrong.  I noticed that the declaration for signal()
in <signal.h> looks as follows:

	extern void	(*signal(int, void (*) (int, ...)))(int, ...);

Is the header wrong, is gcc overly worried, or is my code wrong?

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"What do you *mean* it's not in the computer!" -- Madonna
Technical Details
Message-ID: <3223@charon.cwi.nl>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uunet!mcsun!hp4nl!charon!guido

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uunet!mcsun!hp4nl!charon!guido
From: guido@cwi.nl (Guido van Rossum)
Newsgroups: comp.std.c
Subject: proper semi-portable use of signal()?
Message-ID: <3223@charon.cwi.nl>
Date: 26 Mar 91 13:15:24 GMT
Article-I.D.: charon.3223
Sender: news@cwi.nl
Lines: 27