错误C2872:"CString":模棱两可的符号 [英] error C2872: 'CString' : ambiguous symbol

查看:542
本文介绍了错误C2872:"CString":模棱两可的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个项目,其中还包括1个其他项目.我的两个项目都是使用在静态库中使用MFC"和"MT"选项构建的.我的第二个项目是一个已成功编译的库,但是当我编译主项目时,出现以下错误:
C:\ Program Files \ Microsoft Visual Studio 10.0 \ VC \ atlmfc \ include \ afxwin.h(3343):错误C2872:``CString'':不明确的符号

谁能告诉我这个错误的真正原因


我试图重新排序包含项并使用名称空间,但没有成功.
我在库代码中的某个地方定义了CString(头文件A中包含的头文件A中的typedef CObjectSimple< pstring> CString).我在应用程序中包含了头文件B

I am building a project in which 1 other project is also included. My both projects are built with "Use MFC in a Static Library" and "MT" options. My second project is a library which is compiled successfully but when i compile my main project i get following errors:
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h(3343): error C2872: ''CString'' : ambiguous symbol

Can anybody tell me the real cause of this error


I am trying to reorder the includes and using namespaces but getting no success.
Somewhere in library code i have defined CString (typedef CObjectSimple<pstring> CString in header file A which is included in header file B. I have included header file B in my app

#pragma once
#include "stdafx.h"
#include "PDFTools.h"

#include <sstream>
#include <myheaderfiles>
#include <myheaderfiles>           //This is header file which is giving error and which include the header file where CString is typedef.
#include <myheaderfiles>
#include <myheaderfiles>
#include <myheaderfiles>
#include <myheaderfiles>
#include <myheaderfiles>
#include <boost/program_options.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <limits>
#include <myheaderfiles>
#include <myheaderfiles>

#ifdef WIN32
#include <Windows.h>
#undef max
#undef min
#endif

using namespace std;
using namespace boost;

using namespace ...;     This is namespace which is getting error
using namespace ...;
namespace ...;



我评论了win32 include,但没有成功.

如您所见,系统文件给出了错误



I commented the win32 include but got no success.

Error is given by system file as u can see

C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h(3331): error C2872: ''CString'' : ambiguous symbol
could be ''C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxstr.h(99) : ATL::CStringT<BaseType,StringTraits> CString''
with
[
BaseType=wchar_t,
StringTraits=StrTraitMFC_DLL<wchar_t>
]
or .....myheaderFilelocation(295) : myclassobject::CString''
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin.h(3361) : see reference to function template instantiation ''TReturnType CWnd::EnlargeBufferGetText<TReturnType,int>(TRetur nType,LPTSTR &,TCchType &,TCchType,TCchType,UINT,WPARAM &,LPARAM &,CString &) throw(...) const'' being compiled
with
[
TReturnType=BOOL,
TCchType=int
]
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxwin4.inl(132) : see reference to function template instantiation ''TReturnType CWnd::EnlargeBufferGetText<BOOL>(TReturnType,LPTST R &,int &,UINT,WPARAM &,LPARAM &,CString &) throw(...) const'' being compiled
with
[
TReturnType=BOOL
]



我忘记告诉的一件事是,此代码在Debug模式下运行良好.释放模式给问题



one thing which i forget to tell is that this code is working fine in Debug mode. Release mode is giving problem

推荐答案

为什么在您的代码NINE TIMES中有这个?

Why do you have this in your code NINE TIMES?

#include <myheaderfiles>



另外,myheaderfiles.h是否也具有以下行:



Also, does myheaderfiles.h also have this line:

#include "stdafx.h"


似乎您要包括MFC CString定义,然后将其定义为其他类型.我有点惊讶typedef没有给您重新定义错误,但是从您所说的来看,它看起来像什么.

干杯,

It looks like you''re including the MFC CString definition and then typedefing it as something else. I''m sort of surprised the typedef doesn''t give you a redefinition error but that what it looks like from what you''ve said.

Cheers,

Ash


这篇关于错误C2872:"CString":模棱两可的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆