Problem with pointer to function - what's wrong here?
- From: Charles Sullivan <cwsulliv@xxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 16:27:33 -0500
I define and initialize an array of structures like the following,
(where the <verbiage within angle brackets> is just meant to be
explanatory):
int func1(<argument prototypes>);
int func2(<argument prototypes>);
struct mystruct {
<other stuff>;
int (*myfunc)();
} myrecords[] = {
{<other stuff value>, func1},
{<other stuff value>, NULL },
{<other stuff value>, func2}
};
int func1(<argument list>)
{
<blah-blah-blah1>
}
int func2(<argument list>)
{
<blah-blah-blah2>
}
I've always believed this was legal code, and have used something
similar a few times in the past, but now when (<argument list>) is:
(unsigned char x1, unsigned char x2, unsigned char x3,
int *y1, unsigned int *y2, int *y3)
I get the compiler message:
"warning: initialization from incompatible pointer type"
What am I doing wrong?
Thanks for your help.
Regards,
Charles Sullivan
.
- Follow-Ups:
- Re: Problem with pointer to function - what's wrong here?
- From: Eric Sosman
- Re: Problem with pointer to function - what's wrong here?
- From: David T. Ashley
- Re: Problem with pointer to function - what's wrong here?
- From: Keith Thompson
- Re: Problem with pointer to function - what's wrong here?
- From: Ben Pfaff
- Re: Problem with pointer to function - what's wrong here?
- Prev by Date: Re: How to improve this sort?
- Next by Date: Re: Problem with pointer to function - what's wrong here?
- Previous by thread: variable initialization / I'm a n00b
- Next by thread: Re: Problem with pointer to function - what's wrong here?
- Index(es):
Relevant Pages
|