随笔-10  评论-1  文章-0  trackbacks-0

今天没事用VS2005打开一个COM应用原理的源代码,一运行就报错,然后修改来修改去,最终有2个主要错误:
1. 不能将参数  从“const wchar_t [ ]”转换为“String”

2.无法解析的外部符号 "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)“

第一个问题我发现源码中String被定义为
typedef unsigned short *String;
翻阅MSDN里面有段话

By providing overloads for both the unsigned short and __wchar_t variations of wchar_t, you can create libraries that can easily be linked with code compiled with or without /Zc:wchar_t and avoid the need to provide two different builds of the library (one with and one without /Zc:wchar_t enabled).

意思是要不使用内置的wchar_t类型来避免这两个不同的库冲突
第二个问题也是一样的
具体原因是你导入的库对于wchar_t不是内置类型,以前的vc6都不是,而vc6.0之后的工程缺省都是wchar_t是内建类型,其导出出来的符号是不一样的。所以,你只需要在vc7的project/proterties里面的c/c++   -->language     -->treat   wchar_t   as   build_in   type设置为no,就可以和以前那些库兼容了。所有使用了wchat_t的函数都会有这个问题。
posted on 2010-05-26 05:24 Mr.Johnson 阅读(458) 评论(0)  编辑 收藏 引用 所属分类: 学习笔记

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理