Re: Problem with pointer to function - what's wrong here?
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: 31 Jan 2007 13:41:09 -0800
Charles Sullivan <cwsulliv@xxxxxxxxxxxx> writes:
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?
I don't believe you've given us enough information to answer that.
Show us some actual code that exhibits the problem. You don't have to
post your actual code (which is probably too big to post); you can
just replace <other stuff> with, say, "int x;", and
"<blah-blah-blah11>" with nothing.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- Problem with pointer to function - what's wrong here?
- From: Charles Sullivan
- Problem with pointer to function - what's wrong here?
- Prev by Date: Re: Problem with pointer to function - what's wrong here?
- Next by Date: Re: Problem with pointer to function - what's wrong here?
- Previous by thread: Re: Problem with pointer to function - what's wrong here?
- Next by thread: Re: Problem with pointer to function - what's wrong here?
- Index(es):
Relevant Pages
|