Someguy
Someguy

Reputation: 149

error: expected ')' before '*' token

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.

Upvotes: 0

Views: 1157

Answers (1)

AnT stands with Russia
AnT stands with Russia

Reputation: 320451

The most typical reason for this is circular header inclusion. You include os_memheap_drivers.h into your os_memory_strategies.h (as we can see above). But apparently you also directly or indirectly include os_memory_strategies.h into os_memheap_drivers.h as 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.h ended up being included first, which is why it does not recognize Heap as type name.

Circular header inclusion never works and never achieves anything. Get rid of it, i.e. make sure os_memory_strategies.h in not included into os_memheap_drivers.h.

Upvotes: 1

Related Questions