The struct doesn't need to be defined. It only needs to be declared. The typedef declaration you present subsumes the declaration of struct SYSTEM
.
So it's equivalent to:
struct SYSTEM;
typedef struct SYSTEM SYSTEM;
Thanks to this typedef, SYSTEM
now names an incomplete type, so you can use it like SYSTEM *
in interface definitions, without needing to expose the actual definition of the struct, which can be kept private:
public_header.h:
typedef struct SYSTEM SYSTEM;
SYSTEM * create_system();
int do_useful_thing_with(SYSTEM * system, int count, void * addr);
void destroy_system(SYSTEM * system);
private_impl.c:
#include <public_header.h>
struct SYSTEM { int a; char b[12]; float q; void * next; };
SYSTEM * create_system()
{
SYSTEM * p = malloc(sizeof *p);
if (p) { p->a = 2; p->q = 1.5; }
return p;
}
void destroy_system(SYSTEM * system)
{
free(system);
}
// etc.