用openwrt编译C程序
这是我的结构定义。我使用这种结构的代码在编译器中使用,但当我尝试为另一个模型编译时,它显示 错误:“结构用户”没有名为“ipAddress”的成员 错误:“结构用户”没有名为“macAddress”的成员 所有成员。 有人知道吗? 我正在发布我的部分代码。不可能发布所有代码用openwrt编译C程序,c,struct,C,Struct,这是我的结构定义。我使用这种结构的代码在编译器中使用,但当我尝试为另一个模型编译时,它显示 错误:“结构用户”没有名为“ipAddress”的成员 错误:“结构用户”没有名为“macAddress”的成员 所有成员。 有人知道吗? 我正在发布我的部分代码。不可能发布所有代码 typedef struct{ char startDate[12],endDate[12]; short activeFlag: 8; short ruleNo; int duration;
typedef struct{
char startDate[12],endDate[12];
short activeFlag: 8;
short ruleNo;
int duration;
time_t end_time;
}usagesOnRule;
typedef struct
{
usagesOnRule timeBaseUsages[TIME_BASED_USG_NUM];
time_t lstChrgngAtmptd;
time_t lastUpdateTime;
time_t lastBlockTime;
long long macKey;
uint32_t ipKey;
uint32_t dropPkt;
uint32_t sessionCnt[QTHREAD_SIZE];
int16_t ruleList[USER_RULE_NO], ruleListCounter;
int sessnStart, sessionNFq, resultCode;
short failCount;
short blocked;
short timeBaseCounter;
char macAddress[MAC_LEN];
char ipAddress[IP_LEN];
}user;
user CurrentUser[USER_NUMBER];
for(usrIndx=0;usrIndx0)
{
而(sessnIndx>0)
{
sessionCount++;
sprintf(回复,“%s%s |%d |%s |%s\n”,回复,当前会话[qIndx][sessnIndx]。destp,当前会话[qIndx][sessnIndx]。desport,当前会话[qIndx][sessnIndx]。主机名,当前会话[qIndx][sessnIndx].appProtocol);
sessnIndx=当前会话[qIndx][sessnIndx]。下一步;
}
}
sprintf(回复,“%s\u%d\n的%sTotal\u会话”,回复,当前用户[usrIndx]。macAddress,sessionCount);
}
}
我找到了不使用用户结构编译的原因。对于某些硬件架构,内核模块中有另一个名为“用户”的结构
只是我重新命名了我的结构名称和它的工作良好
干杯 您尚未在显示的代码中定义
struct user
。。。仅用户
(作为未命名结构的typedef)。您是否在代码的其他部分使用struct user
而不是user
?(在C语言中,两者是不可互换的)。您需要向我们展示编译器抱怨的代码,而不是它工作的代码。继续删除所有不需要产生错误的代码,直到您留下了复制错误的最小可能代码。
for (usrIndx = 0; usrIndx < USER_NUMBER; ++usrIndx)
{
if (CurrentUser[usrIndx].ipKey == 0)
continue;
if (strcmp(CurrentUser[usrIndx].macAddress, msg2) == 0)
{
sessnIndx = CurrentUser[usrIndx].sessnStart;
qIndx = CurrentUser[usrIndx].sessionNFq;
sessionCount = 0;
if (CurrentUser[usrIndx].sessnStart > 0)
{
while (sessnIndx > 0)
{
sessionCount++;
sprintf(reply, "%s%s|%d|%s|%s\n", reply, CurrentSession[qIndx][sessnIndx].destIp, CurrentSession[qIndx][sessnIndx].destPort, CurrentSession[qIndx][sessnIndx].hostName, CurrentSession[qIndx][sessnIndx].appProtocol);
sessnIndx = CurrentSession[qIndx][sessnIndx].next;
}
}
sprintf(reply, "%sTotal_Session_of_%s_%d\n", reply, CurrentUser[usrIndx].macAddress, sessionCount);
}
}