简体   繁体   English

C ++错误:ISO C ++禁止声明。 没有类型

[英]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:错误:在'*'标记之前应为','或'...'

ClientManager.h:332: error: ISO C++ forbids declaration of 'TPacketGDCombatZoneResetRanking' with no type ClientManager.h:332:错误:ISO C ++禁止无类型的'TPacketGDCombatZoneResetRanking'声明

ClientManager.h:333: error: expected ',' or '...' before '*' token ClientManager.h:333:错误:在'*'标记之前应为','或'...'

ClientManager.h:333: error: ISO C++ forbids declaration of 'TPacketGDCombatZoneSkillsCache' with no type ClientManager.h:333:错误:ISO C ++禁止声明无类型的'TPacketGDCombatZoneSkillsCache'

ClientManager.h line 332 - 333 ClientManager.h332-333

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

ClientManager.cpp function ClientManager.cpp函数

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. nm的评论引起了人们的关注。

The compiler error message here is very unfortunate (and suggests that you're using an outdated version of GCC). 这里的编译器错误消息是非常不幸的(建议您使用的是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. 问题在于,编译器无法在其中找到您正在使用的类型,因此const some_type* name_of_parameter将参数读取为const some_type* name_of_parameter ,不如将其读取为const name_of_parameter other_stuff_that_shouldnt_be_here ,并抱怨说:1)您不能在没有第一个参数的情况下命名参数给出一个类型和2)您在参数名称后有一些意外的标记(即* )。

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. 您需要使用前向声明来声明类型,或者包括定义它们的标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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