I am trying to pass a typedef struct pointer to a function and the compiler is complaining with this error message: error: unknown type name ‘RootP’. Here is the code…
int main()
{
typedef struct Root
{
struct Root *child;
}*RootP;
RootP rootNode = malloc(sizeof(struct Root));
rootNode->child = NULL;
....
}
void mkdir(RootP rootNode, char param2[60], char pwd[200])
{
...
}
The
structshould be outside ofmain, so movebefore the
mainfunction. If the program is big enough, consider moving that into some header file (*.h)And I would avoid using the
mkdirname. It is defined in Posix and on Linux refers to the mkdir(2) system call.I don’t feel that
typedef struct Root *RootP;is pretty code: you usually want to see at a glance what C thing is a pointer. I would instead declare thestruct root_stand havetypedef struct root_st Root;(Gtk also uses that, or a very similar, coding convention). And codeRoot* rootnode. But it is debatable and a matter of taste.