简体   繁体   中英

Visual Studio 2015 “stealing” the application's console

I'm developing a gcc application using Visual Studio 2015 as an IDE. The debugger is gdb.

The application creates it's own window. When I compile with a DEBUG switch, I need the application to also spawn a console window. It's used for debugging and outputing printf's from multiple threads. Thanks to the "-mwindows" switch, this works correctly when I execute the application from outside Visual Studio.

Unfortunately, when I run the application from within Visual Studio, it seem to steal the console window. No console is spawned, and the printf's output are redirected to the Output Debug window.

This wouldn't be much of a problem if the VS console actually printed the "\\n" correctly instead of stripping them out of the ouput. Everything gets printed on the same line, and the output becomes unreadable. Try as I may, I couldn't get VS to insert a newline in the Output Debug window. I searched online a lot, and this problem seems to be well documented, but I couldn't find a satisfying answer.

At this point, either of these solutions would work for me :

  1. Prevent Visual Studio from stealing the application's console window;
  2. Add special characters to all my printf in order to make the Output Debug print line feeds and carriage returns.

EDIT : Ideally, the solution should be cross-plateform, in a sense that it should not add dependency to WinAPI.

EDIT2 : "\\t" seems to work as intended. Why does "\\n" doesn't work? I also tried "\\r\\n" to no avail.

I was contacted by a Senior PM Manager for Visual Studio at Microsoft regarding this issue. I posted it as a "feedback" inside Visual Studio, about four months ago (around the time I posted it here)..

He acknowledged the problem, and said they're gonna try to add support for external consoles with Update 3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM