Skip to content

Commit db6c5d0

Browse files
committed
Set -mwindows to use Win32 subsystem, attach to parent process console if we have one
1 parent 15e9b59 commit db6c5d0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ngscopeclient/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ else()
2222
set(RC_FILES "")
2323
endif()
2424

25+
if(WIN32 AND (NOT MSVC))
26+
add_compile_options(-mwindows)
27+
endif()
28+
2529
###############################################################################
2630
#C++ compilation
2731
add_executable(ngscopeclient

src/ngscopeclient/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ int main(int argc, char* argv[])
7272
//If on Windows, and not run from a console
7373
//remove the stdout log sink that would otherwise spawn a console on startup
7474
#ifdef _WIN32
75-
if(GetConsoleWindow() == NULL)
75+
if(!AttachConsole(ATTACH_PARENT_PROCESS))
76+
{
77+
LogNotice(
78+
"Startup: skipping stdout log sink since not run from a console "
79+
"(AttachConsole reports parent process has no console)\n");
80+
}
81+
else if(GetConsoleWindow() == NULL)
7682
LogNotice("Startup: skipping stdout log sink since not run from a console (no console window)\n");
7783
else if(getenv("PROMPT") != nullptr)
7884
LogNotice("Startup: skipping stdout log sink since not run from a console (no prompt)\n");

0 commit comments

Comments
 (0)