I recently upgraded the solution of an older project to use visual studio 2015. The application runs an opengl application. The application allocates a separate console for output. I use the console to output relevant debug information from within my opengl application.
I have fully upgraded my project and it works correctly. My problem is that when upgrading my project to use the Visual Studio 2015 (v140) toolset from the Visual Studio 2013 (v120) toolset, the console does not display any information when I use any console output functions (stdio.h or iostream). This makes debugging a bit more of a pain.
To be clear I can swap my project back to use the Visual Studio 2013 (v120) toolset and the console will display information when I output to console.
Does any one have any insight into a reason why the newer toolset prevents me from seeing information in my console window? Am I meant to set up a console differently?
Link with good clear simple example of console output redirection. (I'd give more examples but I'm link limited) http://asawicki.info/news_1326_redirecting_standard_io_to_windows_console.html
example of my console output creation:
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);
This:
*stdout = *fp;
is not valid. FILE
is an opaque type. You are only allowed to manipulate a FILE
via the stdio library functions (fopen
, freopen
, fread
, etc.).
If you want to reopen one of the standard streams to refer to the console, one supported way to do that would be:
freopen("CONOUT$", "w", stdout);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With