Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!sri-spam!nike!ll-xn!mit-amt!mit-eddie!genrad!decvax!tektronix!uw-beaver!tikal!amc!pilchuck!dataio!bright From: bright@dataio.UUCP Newsgroups: net.lang.c Subject: Re: Casting void - int question Message-ID: <1100@dataio.UUCP> Date: Wed, 15-Oct-86 12:54:28 EDT Article-I.D.: dataio.1100 Posted: Wed Oct 15 12:54:28 1986 Date-Received: Thu, 16-Oct-86 06:11:39 EDT References: <26@orion.UUCP> Reply-To: bright@dataio.UUCP (Walter Bright) Organization: Data I/O - FutureNet Corp., Redmond, WA Lines: 34 In article <26@orion.UUCP> heins@orion.UUCP (Michael T. Heins) writes: >I have a number of existing functions with compatible arguments. Some >are declared as void, and others as int. None of the return values are >used. I wish to set up an array of pointers to these functions. >My problem is that the compiler complains about incompatible types, and >I can't figure out how to use casts or unions to solve the problem. >Re-declaring the functions is not an option. I have exemplified the >situation below: > >int fna() { } >void fnb() { } > >int (*array[32])(); >main() { > array[0] = fna; > array[1] = fnb; /* This won't work as-is. */ >} > >I have tried things like > array[1] = (int (*)())fnb; >but this generates the message "operands of CAST have incompatible types". int fna() { } void fnb() { } int callfnb() { fnb(); } int (*array[32])(); main() { array[0] = fna; array[1] = callfnb; } Messy, but workable.