Bläddra i källkod

Console output works once again since port to VS2015

BearishSun 10 år sedan
förälder
incheckning
7d68d63abb
1 ändrade filer med 11 tillägg och 21 borttagningar
  1. 11 21
      BansheeEditorExec/BsEditorExec.cpp

+ 11 - 21
BansheeEditorExec/BsEditorExec.cpp

@@ -16,29 +16,19 @@ void InitializeDebugConsole()
 {
 	//Create a console for this application
 	AllocConsole();
-	//Redirect unbuffered STDOUT to the console
-	HANDLE ConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
-	int SystemOutput = _open_osfhandle(intptr_t(ConsoleOutput), _O_TEXT);
-	FILE *COutputHandle = _fdopen(SystemOutput, "w");
-	*stdout = *COutputHandle;
-	setvbuf(stdout, NULL, _IONBF, 0);
-
-	//Redirect unbuffered STDERR to the console
-	HANDLE ConsoleError = GetStdHandle(STD_ERROR_HANDLE);
-	int SystemError = _open_osfhandle(intptr_t(ConsoleError), _O_TEXT);
-	FILE *CErrorHandle = _fdopen(SystemError, "w");
-	*stderr = *CErrorHandle;
-	setvbuf(stderr, NULL, _IONBF, 0);
 
-	//Redirect unbuffered STDIN to the console
-	HANDLE ConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
-	int SystemInput = _open_osfhandle(intptr_t(ConsoleInput), _O_TEXT);
-	FILE *CInputHandle = _fdopen(SystemInput, "r");
-	*stdin = *CInputHandle;
-	setvbuf(stdin, NULL, _IONBF, 0);
+	// Redirect standard output to console
+	freopen("CONIN$", "r", stdin);
+	freopen("CONOUT$", "w", stdout);
+	freopen("CONOUT$", "w", stderr);
 
-	//make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
-	std::ios::sync_with_stdio(true);
+	// Clear streams to ensure they aren't in an error state
+	std::wcout.clear();
+	std::cout.clear();
+	std::wcerr.clear();
+	std::cerr.clear();
+	std::wcin.clear();
+	std::cin.clear();
 }
 
 void ShutdownDebugConsole()