1

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.

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). Character Set = 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;
}

It crashes on zs << "Hello";

Adrian P
  • 105
  • 8
  • Elaborate _just crash_ please! You are probably missing some DLLs or bind to the wrong ones. – πάντα ῥεῖ Aug 18 '15 at 18:00
  • The redist DLLs are there. I have them for each version from 2010 to 2013 (msxxx100.dll, 110.dll and 120.dll). When you are missing the corresponding redist dlls, a problem doesn't crash. The OS displays a message that a the required DLL is missing. The crashes happen when I try to append to zs. In this example, it crashes on the line zs << "Hello"; If I compile using the 2010 platform it works fine. It crashes when I compile using either the 2012 or 2013 XP platform, both of which are supposed to work on XP/Server 2003. – Adrian P Aug 18 '15 at 18:02
  • What's the exception/compiler error message? Usually programs don't _"just crash'_ silently. – πάντα ῥεῖ Aug 18 '15 at 18:05
  • ILLEGAL_INSTRUCTION (0xc000001d) at address 0x00416ab9. I can comment out the line zs << "Hello" and then no exception occurs. – Adrian P Aug 18 '15 at 18:20
  • Did you try `zs << L"Hello";` already? May be it's a problem with multibyte character recognition. – πάντα ῥεῖ Aug 18 '15 at 18:27
  • While zs << L"Hello"; doesn't cause an exception, the output is not Hello. I get 00420E0C instead. So looks like you're on the right track. I looked up multi-byte support and it looks like the DLLs are available as a seperate download. https://msdn.microsoft.com/en-us/library/5z097dxa.aspx – Adrian P Aug 18 '15 at 18:42

1 Answers1

1

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

Adrian P
  • 105
  • 8