Article View: net.lang.c
Article #9584Casting void - int question
From: Michael T. Heins
Date: Mon, 13 Oct 1986 16:00
Date: Mon, 13 Oct 1986 16:00
33 lines
1445 bytes
1445 bytes
[]
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
Technical Details
Message-ID:
<26@orion.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!think!nike!sri-spam!sri-unix!hplabs!sdcrdcf!trwrb!orion!heinsShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!think!nike!sri-spam!sri-unix!hplabs!sdcrdcf!trwrb!orion!heins From: heins@orion.UUCP (Michael T. Heins) Newsgroups: net.lang.c Subject: Casting void - int question Message-ID: <26@orion.UUCP> Date: Mon, 13-Oct-86 12:00:39 EDT Article-I.D.: orion.26 Posted: Mon Oct 13 12:00:39 1986 Date-Received: Fri, 17-Oct-86 20:06:22 EDT Organization: TRW Digital Development Laboratory, Manhattan Beach, CA Lines: 33