Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
7ee09b81
Commit
7ee09b81
authored
Apr 04, 2017
by
Martin Schultz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use macro during console creation on windows
parent
ceb7fc99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
38 deletions
+18
-38
OpenFlipper.cc
OpenFlipper.cc
+18
-38
No files found.
OpenFlipper.cc
View file @
7ee09b81
...
...
@@ -111,62 +111,42 @@
#ifdef WIN32
#define CONNECT_CONSOLE \
FILE* check = freopen("CONIN$", "r", stdin); \
if (check) { \
std::cerr << "Error reopening stdin" << std::endl; \
} \
check = freopen("CONOUT$", "w", stdout); \
if (check) { \
std::cerr << "Error reopening stdout" << std::endl; \
} \
check = freopen("CONOUT$", "w", stderr); \
if (check) { \
std::cerr << "Error reopening stderr" << std::endl; \
}
void
attachConsole
()
{
//try to attach the console of the parent process
if
(
AttachConsole
(
-
1
))
{
//if the console was attached change stdinput and output
FILE
*
check
=
freopen
(
"CONIN$"
,
"r"
,
stdin
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stdin"
<<
std
::
endl
;
}
check
=
freopen
(
"CONOUT$"
,
"w"
,
stdout
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stdout"
<<
std
::
endl
;
}
check
=
freopen
(
"CONOUT$"
,
"w"
,
stderr
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stderr"
<<
std
::
endl
;
}
CONNECT_CONSOLE
}
else
{
//create and attach a new console if needed
#ifndef NDEBUG
//always open a console in debug mode
AllocConsole
();
AllocConsole
();
CONNECT_CONSOLE
FILE
*
check
=
freopen
(
"CONIN$"
,
"r"
,
stdin
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stdin"
<<
std
::
endl
;
}
check
=
freopen
(
"CONOUT$"
,
"w"
,
stdout
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stdout"
<<
std
::
endl
;
}
check
=
freopen
(
"CONOUT$"
,
"w"
,
stderr
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stderr"
<<
std
::
endl
;
}
return
;
#endif
if
(
OpenFlipper
::
Options
::
logToConsole
())
{
AllocConsole
();
FILE
*
check
=
freopen
(
"CONIN$"
,
"r"
,
stdin
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stdin"
<<
std
::
endl
;
}
check
=
freopen
(
"CONOUT$"
,
"w"
,
stdout
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stdout"
<<
std
::
endl
;
}
check
=
freopen
(
"CONOUT$"
,
"w"
,
stderr
);
if
(
check
)
{
std
::
cerr
<<
"Error reopening stderr"
<<
std
::
endl
;
}
CONNECT_CONSOLE
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment