Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mit-eddie.UUCP Path: utzoo!linus!decvax!genrad!mit-eddie!mp From: mp@mit-eddie.UUCP (Mark Plotnick) Newsgroups: net.lang.c Subject: ptrs to functions Message-ID: <628@mit-eddie.UUCP> Date: Sun, 21-Aug-83 18:26:49 EDT Article-I.D.: mit-eddi.628 Posted: Sun Aug 21 18:26:49 1983 Date-Received: Mon, 22-Aug-83 01:25:17 EDT Organization: MIT, Cambridge, MA Lines: 20 This addresses-of-arrays business made me wonder what happens when you try to pass functions as parameters. Now, all you people who grew up with the V7 C compiler know that, in order to pass a function as a parameter, all you need do is mention the function's name in the actual parameter list. The declaration of the formal would look something like "int (*func)();", and to invoke it you'd do something like "j = (*func)(i)". With 4.1bsd pcc, the rules are a bit lax. You can declare a formal as "int func();" and only get a mild warning. You can even do "j = func(i)" and get no warning at all. In both cases, func is really a pointer to the function. I'm not going to take a stand as to whether or not the pcc rules violate the definition of C; after all, the most recent C reference manual is from 1979 or so, and who knows what's changed since then. But pcc's extensions make the job of porting code to V7 a pain, sometimes. Mark (genrad!mit-eddie!mp, eagle!mit-vax!mp)