I receive this error when compiling my code and got absolutely no idea after trying out for an hour.
This is the file which causes the error os_memory_strategies.h:
#ifndef _OS_MEMORY_STRATEGIES_H
#define _OS_MEMORY_STRATEGIES_H
#include "os_mem_drivers.h"
#include "os_memheap_drivers.h"
#include "os_process.h"
#include "defines.h"
#include <stdint.h>
MemAddr os_Memory_FirstFit (Heap *heap, uint16_t size);
#endif
The line
MemAddr os_Memory_FirstFit (Heap *heap, uint16_t size);
causes the error. As I understand “Heap” is unknown to this point. The struct Heap is defined in os_memheap_drivers.h which is included here. The struct looks like this:
typedef struct Heap{
prog_char *const name;
MemDriver *const driver;
AllocStrategy allocStrat;
Memory const memory;
}Heap;
Using AVRStudio and all the files are in the same directory.
The most typical reason for this is circular header inclusion. You include
os_memheap_drivers.hinto youros_memory_strategies.h(as we can see above). But apparently you also directly or indirectly includeos_memory_strategies.hintoos_memheap_drivers.has well.The include guards will naturally “resolve” this circular inclusion is some unpredictable way, i.e. one of these files will end up being included first and the other will end up being included second. In your case
os_memory_strategies.hended up being included first, which is why it does not recognizeHeapas type name.Circular header inclusion never works and never achieves anything. Get rid of it, i.e. make sure
os_memory_strategies.hin not included intoos_memheap_drivers.h.