[net.lang.c] pointers to void functions

clarke@h-sc1.UUCP (cam clarke) (02/14/86)

I wrote this piece of code to experiment with catching signals under 4.2 BSD
Unfortunately, cc and lint don't like the assignment "tch = catch;"
I can't figure out why, but when I change catch to be an int function and
change tch to point to an int function, my problem disappears. Anyone know
why?

#include <signal.h>
typedef void (*PFV)();

void catch()
{
    printf("Signal Number 2 caught\n");
}

main()
{
    PFV tch;
    tch = catch;
    (void) signal (2,catch);
    while(1) ;
}

			-Cam Clarke
			clarke@h-sc4.HARVARD.EDU
			clarke@h-sc4.UUCP

chris@umcp-cs.UUCP (02/16/86)

In article <943@h-sc1.UUCP> clarke@h-sc1.UUCP writes:

>I wrote this ... under 4.2 BSD. Unfortunately, cc and lint don't like
>the assignment "tch = catch;"

where `tch' is `pointer to function returning void', and `catch' is
`function returning void'.

`void' types are somewhat broken in the 4.2BSD PCC.  Use `-Dvoid=int'
for now, or avoid void.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

jdz@wucec2.UUCP (02/18/86)

In article <943@h-sc1.UUCP> clarke@h-sc1.UUCP (cam clarke) writes:
>I wrote this piece of code to experiment with catching signals under 4.2 BSD
>Unfortunately, cc and lint don't like the assignment "tch = catch;"
>I can't figure out why, but when I change catch to be an int function and
>change tch to point to an int function, my problem disappears. Anyone know
>why?
 [code omitted]
4.2 has some known deficiencies in its handling of void. The one you bring
up (catch is a function returning void, tch is of type pointer to function
returning void) is one of these. 4.3BSD cc fixes these bugs and results in
consistent handling of void. 4.3 should be available Real Soon Now.

Hope the workaround doesn't hurt too bad...
-- 
Jason D. Zions			...!{seismo,cbosgd,ihnp4}!wucs!wucec2!jdz
Box 1045 Washington University
St. Louis MO 63130  USA		(314) 889-6160
Nope, I didn't say nothing. Just random noise.