I have the following files in my VS project:
// list.h
#include "node.h"
typedef struct list list_t;
void push_back(list_t* list_ptr, void* item);
// node.h
typedef struct node node_t;
// node.c
#include "node.h"
struct node
{
node_t* next;
};
// list.c
#include "list.h"
struct list
{
node_t* head;
};
void push_back(list_t* list_ptr, void* item)
{
if(!list_ptr)
return;
node_t* node_ptr; // Here I have two compiler errors
}
I have the compiler errors: Compiler Error C2275 and Compiler Error C2065.
Why? How can i fix this problem?
list_t. That type has not been defined.#includedthe header files in list.c?_t. Besides the fact that it is useless, it is also reserved by POSIX. You can safely writetypedef struct node nodeand usenodeinstead of introducingnode_t.