🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #499

Re: Question about function pointers & prototypes

#499
From: Tom Neff
Date: Sat, 26 Aug 1989 16:28
18 lines
1400 bytes
In article <1611@agora.UUCP> rickc@agora.UUCP (Rick Coates) writes:
>I am using an array of pointers to functions to access procedures.  My
>compiler complains about lacking a function prototype.  Since the 
>procedures take from none to four differing parameters, how do I declare it?

If the list of function pointers is such that the Nth entry is always
a function of a certain declaration, while the N+1th is always a function
of a certain OTHER declaration, etc., then it is probably better to use
a structure here than an array.  The structure declaration will let you
provide explicit prototypes for the component function (pointers).  If
one or more entries in the list really do take a variable number of
parameters, then the standard pANS "varargs" can be used in their
declaration within the structure.

This is a standard solution for installable drivers and the like.
-- 
"We walked on the moon --	((	Tom Neff
	you be polite"		 )) 	tneff@bfmny0.UU.NET
Technical Details
Message-ID: <14594@bfmny0.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!bfmny0!tneff
References: <1611@agora.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!bfmny0!tneff
From: tneff@bfmny0.UUCP (Tom Neff)
Newsgroups: comp.std.c
Subject: Re: Question about function pointers & prototypes
Message-ID: <14594@bfmny0.UUCP>
Date: 26 Aug 89 16:28:18 GMT
References: <1611@agora.UUCP>
Reply-To: tneff@bfmny0.UU.NET (Tom Neff)
Organization: ^
Lines: 18