LoginSignup
23
13

More than 5 years have passed since last update.

RustでWindowsのコマンドプロンプトウィンドウを抑止する方法

Posted at

 Rust1.18以上でWindows向けのGUIがあるようなプログラムを書く時、コンソール(コマンドプロンプト)ウィンドウを出したくない場合は次のアトリビュートで出さないようにできる。Visual C++で/SUBSYSTEM:WINDOWSにするのと同じような効果。

#![windows_subsystem = "windows"]

 ただし、これだけでは標準出力等が表示されなくなってしまうので、cargo buildのようなデバッグモードではコンソールを有効にしてcargo build --releaseのようなリリースモードでは無効にしたい場合は次のようにする。

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
23
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
13