2

I've scanned most of the pointer initialization warnings and struct initialization questions but nothing seems to quite math my problem.

My question is most similar to that asked Jul 27 '11 at 23:28 by user bhinesley. but in my case my struct only contains function pointers - 2 of them.

I declared it like this in my header:

typedef int (*CRCchecker)(PktDescriptr, ringbuffr, int); type

typedef struct
{
    CRCchecker CRCcheckPROC ;//(PktDescriptr, ringbuffr, int); 
    CRCchecker CRCmakePROC ; //(PktDescriptr, ringbuffr, int); 
} PIDprocs;

Then I defined and initialized it in my source file like this:

PIDprocs CRCcheckrs[16] ={
{NULL, NULL},
{CRCtokenCheck, CRCtokenMake},
{&CRChndshakeCheck, &CRChndshakeMake},
{&CRCdataCheck, &CRCdataMake},
{&CRCtokenCheck, &CRCtokenMake},
{&CRCtokenCheck, &CRCtokenMake},
{&CRChndshakeCheck, &CRChndshakeMake},
{&CRCdataCheck, &CRCdataMake},
{&CRCsplitCheck, &CRCsplitMake},
{&CRCtokenCheck, &CRCtokenMake},
{&CRChndshakeCheck, &CRChndshakeMake},
{&CRCdataCheck, &CRCdataMake},
{&CRCtokenCheck, &CRCtokenMake},
{&CRCtokenCheck, &CRCtokenMake},
{&CRChndshakeCheck, &CRChndshakeMake},
{&CRCdataCheck, &CRCdataMake}};

I declared the array as extern in the same header file (after the typedefs above):

extern PIDprocs CRCcheckrs[16] ;

I defined the functions in the source code then copied their defn to the same header file and declared them as extern (below the extern for the array):

extern int CRChndshakeMake(PktDescriptr usbPkt, ringbuffr* usbPktpload, int* CRCcalc) ;
extern int CRChndshakeCheck(PktDescriptr usbPkt, ringbuffr* usbPktpload,int*CRCcalc)  ;

etc.

It compiles ok but give the dreaded warning:initialization form incompatible pointer type I tried assignment by member name as well as leaving out the & (see 2nd array element)

what is wrong and how can I fix it?

1 Answer 1

3
int CRChndshakeMake(PktDescriptr usbPkt, ringbuffr* usbPktpload, int* CRCcalc)

does not match your declaration;

typedef int (*CRCchecker)(PktDescriptr, ringbuffr, int);

It's apparently disagreeing on some pointers.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that was the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.