开发者

error: expected specifier-qualifier-list before ‘ObjectP’ in c - CIRCULAR DEPENDENCY

开发者 https://www.devze.com 2023-03-30 00:24 出处:网络
I\'ve written a little header file, and I keep getting this error: expected specifier-qualifier-list before ‘ObjectP’

I've written a little header file, and I keep getting this error:

expected specifier-qualifier-list before ‘ObjectP’

I've been looking for an answer and I understand that it's becau开发者_C百科se of the way the compiler parses the text. ObjectP is defined in GenericHashTable.h which is included as you can see. I've tried writing the #include AFTER defining the struct, didn't help. Here's the problematic code with error line marked:

#include "GenericHashTable.h"

typedef struct List* ListP;
typedef struct List
{
    unsigned int size;
    ObjectP head; <----- ERROR HERE
} List;

Any ideas? thanks!

EDIT: I think I know where the problem is. "List.h" includes "GenericHashMap.h" and vice versa, so I have kind of a circular dependency. When I remove the #include statement from one of them it compiles OK and the other one gets the error message.

Must I somehow break this circle, or is there another solution? Thanks!


I'm not 100% sure of this solution, since I do not see your GenericHashTable.h. But It would help if you make the definition of ObjectP in another header file which is included by your GenericHashTable.h and your header defining the list.

0

精彩评论

暂无评论...
验证码 换一张
取 消