I have the below project structure:
file - a.h
#pragma once
struct best_fit_struct {
void *next;
size_t size;
};
file - b.h
#pragma once
typedef struct mm_t {
int type;
union {
struct best_fit_struct best_fit_mm;
} per_mm_struct;
void *memory;
} mm_t;
file - b.c
#include "a.h"
#include "b.h"
on compiling b.c using gcc -c b.c
, it throws the following error
file best_fit_mm has incomplete data type
I have included a.h
before b.h
, so the ordering looks proper to me.
Surprisingly, if I include a.h
inside b.h
, things gets resolved.