I have a header file port.h, port.c, and my main.c
I get the following error: \'ports\' uses undefined struct \'port_t\'
I thought as I have declared the str
A common solution that I use:
/* port.h */
typedef struct port_t *port_p;
/* port.c */
#include "port.h"
struct port_t
{
unsigned int port_id;
char name;
};
You use the port_p in function interfaces. You will need to create special malloc (and free) wrappers in port.h as well:
port_p portAlloc(/*perhaps some initialisation args */);
portFree(port_p);