[lug] C programming Q.

Michael J. Hammel mjhammel at graphics-muse.org
Wed Apr 17 10:54:41 MDT 2002


I hate this.  We're using some gawd-awful args to gcc that force all
warnings into errors so compiles fail.  Ick.  I've cleaned up most of them,
but now I've hit one that I've never hit before.

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

So how do I specify the initialization so that this error (re: warning)
goes away?  I've tried these:

	{"Stuck Address", test_stuck_address(), someval}
	{"Stuck Address", &test_stuck_address, someval}

But neither works.  Does it need a special casting?  Anyone got a suggestion?
-- 
Michael J. Hammel           |
The Graphics Muse           |          Ambivalent? Well, yes and no.
mjhammel at graphics-muse.org  |
http://www.graphics-muse.com 



More information about the LUG mailing list