我尝试纠正代码中的最后一个错误。我已经把VS6.0.0移植到VS2008了。
我的最后一个错误在我的SimpleNPC.cpp文件中:
.\SimpleNPC.cpp(216) : error C2872: 'NPC' : ambiguous symbol
could be '.\SimpleNPC.cpp(30) : NPC_Editor::NPC `anonymous-namespace'::NPC'
or 'c:\documents and settings\t411\bureau\serveur\server_rc15g\t4c server\NPC_Editor/NPC.h(27) : NPC_Editor::NPC'这里的错误代码是:
case InsSendSoldItemList:{
std::list< NPC::SoldItem > itemList;
std::list< NPC::SoldItem >::iterator i;
npc->theNpc->GetSoldItemList( itemList );
CreateItemList
for( i = itemList.begin(); i != itemList.end(); i++ ){
AddBuyItem( (*i).price, Unit::GetIDFromName( (*i).itemId.c_str(), U_OBJECT, TRUE ) )
}
SendBuyItemList文件的开头为:
// SimpleNPC.cpp: implementation of the SimpleNPC class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TFC Server.h"
#include "SimpleNPC.h"
#include "NPCMacroScriptLng.h"
#undef Command
#include "NPC_Editor/NPC.h"
#include "NPC_Editor/Keyword.h"
#include "NPC_Editor/Command.h"
#include "NPC_Editor/IfFlow.h"
#include "NPC_Editor/Assign.h"
#include "NPC_Editor/ForFlow.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
using namespace NPC_Editor;
namespace{
typedef list< Instruction * > InstructionList;
typedef NPC_Editor::NPC NPC;
};在此文件中,我们可以找到以下代码:
std::list< NPC_Editor::NPC::SoldItem > soldItems;你知道为什么会有冲突吗?谢谢!
发布于 2016-10-18 19:04:04
using namespace NPC_Editor;
namespace{
typedef list< Instruction * > InstructionList;
typedef NPC_Editor::NPC NPC;
};首先请注意,在名称空间的右大括号中不需要使用;。
using namespace NPC_Editor;使得可以从全局范围内访问NPC。typedef NPC_Editor::NPC NPC;在匿名名称空间中声明了一个名称NPC,因此可以从全局作用域访问。
您的问题就是编译器所说的:一个名称有两个可能的符号,这是不明确的。删除你的typedef应该可以解决这个问题。
https://stackoverflow.com/questions/40106323
复制相似问题