结构体指针使用时出现dereferencing pointer to incomplete type错误
struct定义如下:
typedef struct role {
char name[40];
int juniorCount;
int seniorCount;
int userCount;
int permissionCount;
int activeUser[50];
struct role_t* juniorRoles[50];
struct role_t* seniorRoles[50];
struct user_t* users[50];
struct permission_t* permissions[50];
} role_t;
在一个函数里用到,在红色的地方报错:dereferencing pointer to incomplete type
蓝色的地方有warning: assignment from incompatible pointer type :
int add_senior_role(role_t* junior, role_t* senior)
{
int i = 0;
//If the junior is already assigned as a junior role of the senior the call fails.
for(; i < senior->juniorCount; i++)
if(strcmp(junior->name, senior->juniorRoles[i]->name) == 0)
return 0;
//A role can have at most 50 junior roles.
if(senior->juniorCount < 50)
{
senior->juniorRoles[senior->juniorCount] = junior; senior->juniorCount++;
}
else
{
printf("No more junior roles can be assigned to this role.\n");
return 0;
}
//A role can have at most 50 senior roles.
if(junior->seniorCount < 50)
{
junior->seniorRoles[junior->seniorCount] = senior;
junior->seniorCount++;
}
else
{
printf("No more senior roles can be assigned to this role.\n");
return 0;
}
return 1;
}
有谁知道怎么改吗?