Skip to content

Commit a955e26

Browse files
committed
Enable printing to console with Windows subsystem
1 parent d4cc410 commit a955e26

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/main.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
1+
#![windows_subsystem = "windows"]
22
#![allow(non_snake_case)]
33

44
mod backend;
55
mod background;
66
mod compact;
77
mod compression;
8+
mod config;
89
mod folder;
910
mod gui;
1011
mod persistence;
11-
mod config;
12+
13+
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
1214

1315
fn main() {
16+
let mut rc = 0;
17+
18+
// Enable console printing with Windows subsystem
19+
unsafe {
20+
AttachConsole(ATTACH_PARENT_PROCESS);
21+
}
22+
1423
if let Err(e) = std::panic::catch_unwind(gui::spawn_gui) {
1524
eprintln!("Unhandled panic: {:?}", e);
25+
rc = 1;
26+
}
1627

17-
std::process::exit(1);
28+
unsafe {
29+
FreeConsole();
1830
}
31+
32+
std::process::exit(rc);
1933
}

0 commit comments

Comments
 (0)