Casting void - int question

Michael T. Heins heins at orion.UUCP
Tue Oct 14 02:00:39 AEST 1986


[]
Could someone suggest the proper way to handle the following problem?

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".

Any help would be appreciated.

-- 
	...!hplabs!sdcrdcf!trwrb!orion!heins

	We are a way for the universe to know itself. -- Carl Sagan



More information about the Comp.lang.c mailing list