Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watrose.UUCP Path: utzoo!watmath!watrose!dmmartindale From: dmmartindale@watrose.UUCP (Dave Martindale) Newsgroups: net.unix Subject: Re: functions returning pointers to functions Message-ID: <127@watrose.UUCP> Date: Sat, 17-Dec-83 21:27:03 EST Article-I.D.: watrose.127 Posted: Sat Dec 17 21:27:03 1983 Date-Received: Sun, 18-Dec-83 04:46:56 EST References: <2447@azure.UUCP> Organization: U of Waterloo, Ontario Lines: 40 The declaration int (*getroutine(name,table))() declares a function of two arguments which returns a pointer to a function (taking an unknown number of arguments) which returns an integer. At first glance, I would expect that the declaration int (*getroutine())(name,table)) would declare a routine of zero arguments which returns a pointer to a function of two arguments which returns an integer. But in a declaration of a function, you declare only the parameters to that function, not the parameters which would be passed to any function to which this function may return a pointer. So the declaration should read int (*getroutine())() if getroutine takes no arguments, regardless of what sort of arguments the pointed-to function wants. All of the above applies to the actual function definition. In an external declaration, no arguments to any of the functions are specified, and you would use int (*getroutine())(); for both of the cases discussed. IF C were a language in which the types of arguments were checked and type conversion done automatically, you would see declarations like int (*getroutine(name,table))(value,new,old) char *name; struct tab *table; int value; struct entry *new, **old; where the arguments of both getroutine itself and the routine it returns must be declared. But it isn't - you're responsible for getting the number and types of arguments correct yourself. And since you're not even syntactically allowed to put in the "extra" information about the arguments of the returned routine, there isn't anything for lint to check your code against. Caveat programmer. Dave Martindale