Problems with Visual Studio 2015 with connected console I / O

I recently updated an old project solution to use visual studio 2015. The application launches the opengl application. The application provides a separate console for output. I use the console to output the appropriate debugging information from my opengl application.

I have completely updated my project and it works correctly. My problem is that when updating my project using the Visual Studio 2015 toolkit (v140) from the Visual Studio 2013 toolkit (v120), the console does not display any information when I use any console output functions (stdio.h or iostream) . This makes debugging a little more painful.

To be clear, I can change my project to use the Visual Studio 2013 toolkit (v120), and the console will display information when I exit the console.

Does anyone have an idea of ​​the reason why the new toolkit does not allow me to see information in my console window? I wanted to configure the console differently?


A link with a nice clear, simple example of redirecting to the console. (I would give more examples, but I'm limited to links) http://asawicki.info/news_1326_redirecting_standard_io_to_windows_console.html

example of creating my console:

AllocConsole(); long lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); FILE *fp = _fdopen(hConHandle, "w"); *stdout = *fp; setvbuf(stdout, NULL, _IONBF, 0); 
+5
source share
2 answers

It:

 *stdout = *fp; 

not valid. FILE is an opaque type. You are allowed to control FILE using the stdio library functions ( fopen , freopen , fread , etc.).

If you want to reopen one of the standard threads for linking to the console, one of the supported ways to do this is:

 freopen("CONOUT$", "w", stdout); 
+6
source

Check what is in your debugging-> Options and Settings-> Debugging-> Output Window in VS.

It works well for me if everything on the first label is on and the second label is off (error in data binding).

Hope will work.

0
source

Source: https://habr.com/ru/post/1237606/


All Articles