Fix potential issue with Unicode
Fix potential compilation error C2664: 'HANDLE CreateFileW(LPCWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE)': cannot convert argument 1 from 'const char [8]' to 'LPCWSTR' with Unicode/MBCS, as reported here: https://github.com/root-project/cling/issues/186#issuecomment-404902026
This commit is contained in:
parent
13cbf38ae0
commit
a75d9436bc
@ -19,6 +19,12 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef UNICODE
|
||||
#define filename L"CONOUT$"
|
||||
#else
|
||||
#define filename "CONOUT$"
|
||||
#endif
|
||||
|
||||
namespace textinput {
|
||||
TerminalDisplayWin::TerminalDisplayWin():
|
||||
TerminalDisplay(false), fStartLine(0), fIsAttached(false),
|
||||
@ -31,7 +37,7 @@ namespace textinput {
|
||||
if (!isConsole) {
|
||||
// Prevent redirection from stealing our console handle,
|
||||
// simply open our own.
|
||||
fOut = ::CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||
fOut = ::CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
::GetConsoleMode(fOut, &fOldMode);
|
||||
@ -48,6 +54,8 @@ namespace textinput {
|
||||
HandleResizeEvent();
|
||||
}
|
||||
|
||||
#undef filename
|
||||
|
||||
TerminalDisplayWin::~TerminalDisplayWin() {
|
||||
if (fDefaultAttributes) {
|
||||
::SetConsoleTextAttribute(fOut, fDefaultAttributes);
|
||||
|
Loading…
x
Reference in New Issue
Block a user