用openwrt编译C程序

时间:2016-05-26 16:28:07

标签: c struct

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];

这是我的结构定义。我的代码与这个结构在编译器中工作,但当我试图编译另一个模型,它的显示

  

错误:'struct user'没有名为'ipAddress'的成员    错误:'struct user'没有名为'macAddress'的成员

..............所有成员。 有谁有想法? 我发布了部分代码。它无法发布所有代码

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);
                }
            }

1 个答案:

答案 0 :(得分:1)

我有理由不用用户结构进行编译。对于某些硬件体系结构,内核模块中还有另一个名为“User”的结构。

我刚刚重命名了我的结构名称及其工作正常。

喝彩!