I'm trying to create a structure which contains multiple function pointers, however when I try to create an instance of the structure I get a error "variable "stCmdTable" was declared with a never-completed type".
I have a header file in which I have the following code:
typedef int (*pStCmd) (void);
struct stCmdStruc {
pStCmd id;
pStCmd measure;
pStCmd setRelay;
};
typedef struct stCmdStruct stCmdStruct;
stCmdStruct stCmdTable;
I want to create stCmdTable and assign functions to all the function pointers in the stCmdTable, but when it doesn't like my declaration of stCmdTable.
I've also tried doing something like this, where I try to initialise all the function pointers to functions straight of the bat with my structure defintion, but it really doesn't like this telling me expected a ";" at the end of each line in the struct.
typedef int (*pStCmd) (void);
struct stCmdStruc {
pStCmd id = sendId2;
pStCmd measure = sendMeasurement2;
pStCmd setRelay = setRelay2;
};
typedef struct stCmdStruct stCmdStruct;
stCmdStruct stCmdTable;
Can anyone please shed some light on what I'm doing wrong?
struct stCmdStruc!=struct stCmdStruct. You typo'dstructbeforestCmdStructor addtypedef struct stCmdStruct stCmdStruct;.