问题描述
我需要维护一些较旧的C ++应用程序/服务,它们可以在Windows 2003上运行(不是通过选择).我已经准备好了所有东西,并且可以使用VS 2013,但是现在我无法让任何C ++项目再次正常工作.他们只是崩溃.我将其范围缩小到使用stringstream的时间,所以我编写了一个示例Win32 exe进行测试.
I have some older C++ applications/services that I need to maintain which run on Windows 2003 (not by choice). I had things all set and working with VS 2013, but now I can't get any of the C++ projects working again. They just crash. I narrowed it down to when stringstream is used so I wrote a sample Win32 exe to test with.
这些是我在VS 2013 Update 5中更改的唯一设置:设置为使用平台工具集= Visual Studio 2013-Windows XP(v120_xp).特点设置=使用多字节字符集.
These are the only settings I've changed in VS 2013 Update 5:Set to use Platform Toolset = Visual Studio 2013 - Windows XP (v120_xp). CharacterSet = Use Multi-Byte Character Set.
int _tmain(int argc, _TCHAR* argv[])
{
ostringstream zs;
zs << "Hello";
string strTemp = zs.str();
printf("%s\n", zs.str().c_str());
return 0;
}
它在zs<<上崩溃你好";
It crashes on zs << "Hello";
推荐答案
在Visual Studio 2013和更高版本中,用于多字节字符编码(MBCS)的MFC库是作为Visual Studio的单独附加组件提供的.从MSDN下载站点下载.
In Visual Studio 2013 and later, the MFC libraries for multi-byte character encoding (MBCS) is provided as a seperate add-on for Visual Studio which may be downloaded from the MSDN download site.
https://msdn.microsoft.com/en-us/library/5z097dxa.aspx
这篇关于使用ostringstream导致程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!