gpt4 book ai didi

c++ - C++ WDK STL 是否支持 wchar_t?我得到未解析的外部符号的 :(

转载 作者:行者123 更新时间:2023-11-30 00:58:35 24 4
gpt4 key购买 nike

我正在编译一个普通的 C++ 文件Temp.cpp:

#include <string>
int main() { std::wstring s; }

使用命令行:

cl.exe /MD /Iinc\api\crt\stl60 /Iinc\crt /Iinc\api C:\Temp.cpp
/LibPath:lib\wxp\i386 /LibPath:lib\crt\i386
/link /LibPath:lib\wxp\i386 /LibPath:lib\crt\i386

在 WDK 7.1 Windows XP 免费构建环境中。

我收到类似 (LNK2019) 的链接错误:

unresolved external symbol "__declspec(dllimport) public: __thiscall
std::basic_string<wchar_t,struct std::char_traits<wchar_t>,
class std::allocator<wchar_t> >::~basic_string<wchar_t,
struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(void)"
(__imp_??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator
@_W@2@@std@@QAE@XZ) referenced in function _main

如果我使用 string 而不是 wstring,它就可以工作。

问题的原因是什么?如何在我的源文件中使用基于 wchar_t 的类型?

最佳答案

可能的解决方法是设置/Zc:wchar_t- 以关闭 wchar_t 作为固有类型。 STL6 对/Zc:wchar_t 没有很好的支持,这是至少从 VC7.1 开始的默认设置,也许更早。

Meta:请不要使用 STL60 版本的 STL。 1998 年的这个版本缺少现代 STL 中可以找到的大量错误修复、性能改进和标准一致性工作。如果您使用的是 VC 编译器工具链,则免费的 VC++ Express 包括 STL。

马丁

关于c++ - C++ WDK STL 是否支持 wchar_t?我得到未解析的外部符号的 :(,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5988457/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com