| 46 | #endif |
| 47 | |
| 48 | bool openConsole(bool attach, bool alloc) |
| 49 | { |
| 50 | if ((attach && AttachConsole(ATTACH_PARENT_PROCESS)) || (alloc && AllocConsole())) |
| 51 | { |
| 52 | *stdin = *_tfdopen(_open_osfhandle(reinterpret_cast<intptr_t>(::GetStdHandle(STD_INPUT_HANDLE)), _O_RDONLY), _T("r")); |
| 53 | *stdout = *_tfdopen(_open_osfhandle(reinterpret_cast<intptr_t>(::GetStdHandle(STD_OUTPUT_HANDLE)), _O_WRONLY), _T("a")); |
| 54 | *stderr = *_tfdopen(_open_osfhandle(reinterpret_cast<intptr_t>(::GetStdHandle(STD_ERROR_HANDLE)), _O_WRONLY), _T("a")); |
| 55 | |
| 56 | //make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well |
| 57 | std::ios::sync_with_stdio(true); |
| 58 | return true; |
| 59 | } |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | void autoOpenConsole(bool attach, bool alloc) |
| 64 | { |
no outgoing calls
no test coverage detected