[lug] C programming Q.
Archer Sully
archer at aeneas.goldenagewireless.net
Wed Apr 17 11:02:23 MDT 2002
On Wednesday 17 April 2002 10:54, you wrote:
> We have a struct that has a function pointer as a member, such as:
>
> typedef struct teststruct{
> char *name;
> int (*fp) (void);
> int test_type;
> } teststruct_0;
>
> An initialization using this struct looks like this:
>
> teststruct_0 tests_noarg[] =
> {
> {"Stuck Address", test_stuck_address, someval}
> }
>
> The function "test_stuck_address" has this prototype:
>
> int test_stuck_address (uint *val1, uint *val2, uint count);
>
> During compile, the error we get is this:
>
> file.c:xxx: warning: initialization from incompatible pointer type
>
Correct. The prototype of the function pointer does not match
the function that you are trying to pass. You need to change the
fp to int (*fp)(uint *, uint *, uint). Then it should all work. Of course,
I'm too lazy to try it myself... ;-)
-- archer
More information about the LUG
mailing list