Mail Archives: djgpp/2000/12/18/14:42:06
Found the fix.
If I do the following in the structure, The error disappeared.
int Myfunct(int x, void *adr);
typedef struct _MyStruct{
int (*funct)(); //don't include the parameter list
}MyStruct;
in the code I do this:
int x;
void *adr;
MyStruct DefineStruct; //define the structure
DefineStruct.funct = MyFunct; //set the pointer to function
DefineStruct.funct(x, addr); //call the function
On Mon, 18 Dec 2000 18:55:56 GMT, jvasquez AT getntds DOT spam DOT com (John
Vasquez) wrote:
>I have the latest DJGPP compiler.
>
>I use a lot of pointer to functions - If I define it this way I get no
>compiler warning (assignment from incompatible pointer type)
>int Myfunct(void);
>typedef struct _MyStruct{
> int (*funct)(void);
>}MyStruct;
>
>in the code I do this:
>MyStruct DefineStruct; //define the structure
>DefineStruct.funct = MyFunct; //set the pointer to function
>DefineStruct.funct(); //call the function
>}
>
>When I have a function that I pass parameters: like this
>int Myfunct(int x, void *adr);
>
>typedef struct _MyStruct{
> int (*funct)(int x, void *adr);
>}MyStruct;
>
>in the code I do this:
>int x;
>void *adr;
>MyStruct DefineStruct; //define the structure
>DefineStruct.funct = MyFunct; //set the pointer to function <---
>Generates a compiler warning message
>DefineStruct.funct(x, addr); //call the function
>}
>I get the following compiler warning error at DefineStruct.funct =
>MyFunct;
>
>Why? The code I am using was ported over from MS C compiler version
>6.0. and I am modifying the code for 32 bit operations. The MS C
>compiler never generated a warning error and the program works
>perfectly in DOS.
>
>Thank you
>John
- Raw text -