[net.lang.c] Quirk in assignment of pointers to functions ..

badri@ur-helheim.UUCP (Badri Lokanathan) (01/29/86)

The following problem may have been discussed before on this
newsgroup; I came across it just recently. 

Consider the following (perfectly valid) statements:
int abc(), (*f)();
   .
   .
   .
f = abc;

This works (as per K & R) and all is well.
Now consider 
void abc(), (*f)();
   .
   .
   .
f = abc;

This was not accepted by our preprocessor (we run BSD4.2). However, code
equivalent to this appears in spice3 (the latest release of spice
from Berkeley.) I understand spice3 was written on BSD4.3, which leads
me to believe that the 4.3 preprocessor handles things slightly
differently. Any comments??

Badri
 ___________________________________________________________________
'								    `
| ARPA    : ur-helheim!badri@rochester.arpa			    |
| UUCP	  : {allegra,cmcl2,cornell,decvax,harvard,seismo,topaz}	    |
| 	    !rochester!ur-helheim!badri 	    		    |
| USMAIL  : 56 Lansdale St. Rochester NY14620			    |
| PHONE   : off. (716)-271-6624    (716)-275-4066  -5139  	    |
| 	  : res. (716) 442-1578					    |
`-------------------------------------------------------------------'

chris@umcp-cs.UUCP (Chris Torek) (01/30/86)

In article <437@ur-helheim.UUCP> badri@ur-helheim.UUCP writes:

> void abc(), (*f)();
>  ...
> f = abc;
>
> was not accepted by our preprocessor (we run BSD4.2).  [This]
> leads me to believe that the 4.3 preprocessor handles things slightly
> differently.

The bug in not in the preprocessor.  Remember: the C preprocessor
knows no C.  It does not care what you feed it.  It is used for
assembly code in the 4BSD kernell, for example.

Anyway, to answer the question, the 4.2 compiler mishandles `void';
the 4.3 compiler does not.  Donn Seeley (of F77 compiler fame) fixed
it.  (Thanks, Donn.)
-- 
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