简体   繁体   中英

C++ error: ISO C++ forbids declaration. with no type

Can someone help me with this problem please?
How can i do make this lines to can compile good?

ClientManager.h:332: error: expected ',' or '...' before '*' token

ClientManager.h:332: error: ISO C++ forbids declaration of 'TPacketGDCombatZoneResetRanking' with no type

ClientManager.h:333: error: expected ',' or '...' before '*' token

ClientManager.h:333: error: ISO C++ forbids declaration of 'TPacketGDCombatZoneSkillsCache' with no type

ClientManager.h line 332 - 333

void        CombatZoneResetRanking(const TPacketGDCombatZoneResetRanking* p);
void        UpdateSkillsCache(const TPacketGDCombatZoneSkillsCache* p);

ClientManager.cpp function

void CClientManager::CombatZoneResetRanking(const TPacketGDCombatZoneResetRanking* p)
{
    CDBManager::instance().DirectQuery("UPDATE player.player SET combat_zone_rank = 0 WHERE combat_zone_rank > 0");
    std::auto_ptr<SQLMsg> pMsg(CDBManager::instance().DirectQuery("SELECT * FROM player.combat_zone_ranking_weekly ORDER BY memberPoints DESC LIMIT 3"));   
    if (pMsg->Get()->uiNumRows == 3)
    {
        MYSQL_ROW row;
        int memberRank = 1;
        char szQuery[512 + 1];
        while ((row = mysql_fetch_row(pMsg->Get()->pSQLResult)))
        {
            sprintf(szQuery, "UPDATE player.player SET combat_zone_rank = '%d' WHERE name = '%s'", memberRank, row[0]);
            CDBManager::instance().DirectQuery(szQuery);
            memberRank++;
        }
    }
    else {
        sys_err("The giving ranking medals not was possible because not was exist 3 players on ranking weekly.");
    }
    CDBManager::instance().DirectQuery("TRUNCATE TABLE player.combat_zone_ranking_weekly");
}
void CClientManager::UpdateSkillsCache(const TPacketGDCombatZoneSkillsCache* p)
{
    char szQuery[2048 + 1];
    sprintf(szQuery, 
        "INSERT INTO player.combat_zone_skills_cache (pid, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, skillLevel6) "
            "VALUES('%d', '%d', '%d', '%d', '%d', '%d', '%d') "
                "ON DUPLICATE KEY UPDATE skillLevel1 = '%d', skillLevel2 = '%d', skillLevel3 = '%d', skillLevel4 = '%d', skillLevel5 = '%d', skillLevel6 = '%d'", 
                    p->dwPID, p->dwSkillLevel1, p->dwSkillLevel2, p->dwSkillLevel3, p->dwSkillLevel4, p->dwSkillLevel5, p->dwSkillLevel6, p->dwSkillLevel1, p->dwSkillLevel2, p->dwSkillLevel3, p->dwSkillLevel4, p->dwSkillLevel5, p->dwSkillLevel6);
    CDBManager::instance().DirectQuery(szQuery);
}

cases:

case HEADER_GD_COMBAT_ZONE_RESET_RANKING:
    CombatZoneResetRanking((TPacketGDCombatZoneResetRanking*)data);
    break;

case HEADER_GD_COMBAT_ZONE_SKILLS_CACHE:
    UpdateSkillsCache((TPacketGDCombatZoneSkillsCache*)data);
    break;

nm 's comment hits it on the head.

The compiler error message here is very unfortunate (and suggests that you're using an outdated version of GCC). The problem is that the compiler cannot find the types you're using there, so instead of reading the parameter as const some_type* name_of_parameter , it reads it as const name_of_parameter other_stuff_that_shouldnt_be_here , and complains that 1) you can't name the parameter without first giving a type and 2) you have some unexpected tokens (namely, the * ) after the parameter name.

But the real problem is that the types aren't declared, leading the compiler down the wrong path.

You need to either declare the types with forward declarations, or include the headers that define them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM