似乎是vc8中的string的问题

fixopen 2006-06-23 11:35:00
struct reflectable_class_base {
// make sure we have vtable - we need to be able to dynamic_cast to it
virtual ~reflectable_class_base() {}

defs::string object_reflect_name() const { return m_object_reflect_name; }
private:
template<class me> friend struct reflectable_class ;
std::string m_object_reflect_name;
};

object_reflect_name函数出错。
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it)' : cannot convert parameter 1 from 'const std::string' to 'std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it'



struct wnd_tool_info {
wnd_tool_info() : tip_ctrl_name("default"), m_handler(0) {}

// the event handler for this - in case it's null, we need to recreate (window got destroyed, but
// maybe another one with the same ID got created instead)
volatile detail::event_handler_base * m_handler;

// the function to call, when showing tooltip
mutable tooltip_func m_f;

// the tooltip control we're bound to
defs::string tip_ctrl_name;

};

构造函数出错。
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it)' : cannot convert parameter 1 from 'const char [8]' to 'std::basic_string<_Elem,_Traits,_Ax>::_Has_debug_it'


注:defs::string == std::string
我的环境是vc2005,默认debug配置,编译win32gui 1.6.7.31,工程属性是Win32Application。
默认release配置时,错误仍是这两处,但是变成了:

error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'const char [8]' to 'const std::allocator<_Ty> &'

error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'const std::string' to 'const std::basic_string<_Elem,_Traits,_Ax> &'

单独拿出来这一块做实验(一个朋友试的)似乎没有这个问题。他用的是vc2003。

还有一个可以提供的信息就是,单独编译win32gui(使用它自带的build_library.exe驱动vc8的编译器),没有出现什么问题。成功编译出了lib文件。我觉得这似乎是vc2005 std::string的问题。
...全文
663 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fixopen 2006-08-10
  • 打赏
  • 举报
回复
该问题无解,结之。
fixopen 2006-07-12
  • 打赏
  • 举报
回复
没有意见和建议提出?
ahao 2006-06-24
  • 打赏
  • 举报
回复
MD,强烈抗议CSDN不支持代码缩进,这是"程序员"论坛吗?关键字高亮就算了,代码缩进都不做,眼睛都看花了!!!
DentistryDoctor 2006-06-23
  • 打赏
  • 举报
回复
defs::string???
fixopen 2006-06-23
  • 打赏
  • 举报
回复
谁遇见过这种问题?
red-fly 2006-06-23
  • 打赏
  • 举报
回复
template中不能用CString,而只能用char *
fixopen 2006-06-23
  • 打赏
  • 举报
回复
我也使vsts dev edition,为什么出错呢?
pomelowu 2006-06-23
  • 打赏
  • 举报
回复
namespace defs
{
typedef std::string string;
}

struct reflectable_class_base {
// make sure we have vtable - we need to be able to dynamic_cast to it
virtual ~reflectable_class_base() {}

defs::string object_reflect_name() const { return m_object_reflect_name; }
private:
template<class me> friend struct reflectable_class ;
std::string m_object_reflect_name;
};


VC2005 TS下编译通过。
healer_kx 2006-06-23
  • 打赏
  • 举报
回复
唉,你不知道的。。。我。。。
fixopen 2006-06-23
  • 打赏
  • 举报
回复
我的也是普通的string。
fixopen 2006-06-23
  • 打赏
  • 举报
回复
namespace defs
{
typedef std::string string;
}
xqk 2006-06-23
  • 打赏
  • 举报
回复
VS2005 好像有这个问题,我把VC6的工程转到2003都没问题,转到2005下就有字符串类型匹配错误, 普通字符串类型我用的是
xiaochongvip 2006-06-23
  • 打赏
  • 举报
回复
复杂了。看不懂

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧