Why does closing a console that was started with AllocConsole cause my whole application to exit? Can I change this behavior?

Ah, yes, this is one of the caveats of using the Windows console subsystem. When the user closes the console window (regardless of how the console was allocated), all of the processes that are attached to the console are terminated. That behavior makes obvious sense for console applications (i.e., those that specifically target the console … Read more

Undefined reference to WinMain (C++ MinGW)

Newer Mingw versions support -municode linker option switching to alternate startup code allowing to use wWinMain instead of WinMain (or wmain instead of main). Add it to your command line, linker options in IDE or makefile. g++ other_options_and_arguments -municode Older versions do not support this option. One thing to note is that Visual C++ supports … Read more

What is the range of a Windows HANDLE on a 64 bits application?

MSDN states: Interprocess Communication Between 32-bit and 64-bit Applications 64-bit versions of Windows use 32-bit handles for interoperability. When sharing a handle between 32-bit and 64-bit applications, only the lower 32 bits are significant, so it is safe to truncate the handle (when passing it from 64-bit to 32-bit) or sign-extend the handle (when passing … Read more

Is it reasonable to use std::basic_string as a contiguous buffer when targeting C++03?

I’d consider it quite safe to assume that std::string allocates its storage contiguously. At the present time, all known implementations of std::string allocate space contiguously. Moreover, the current draft of C++ 0x (N3000) [Edit: Warning, direct link to large PDF] requires that the space be allocated contiguously (§21.4.1/5): The char-like objects in a basic_string object … Read more