Skip to content

Update windows_subsystem to use the attribute template #1920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions src/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,36 @@ r[runtime.windows_subsystem]
## The `windows_subsystem` attribute

r[runtime.windows_subsystem.intro]
The *`windows_subsystem` attribute* may be applied at the crate level to set
the [subsystem] when linking on a Windows target.
The *`windows_subsystem` [attribute][attributes]* sets the [subsystem] when linking on a Windows target.

> [!EXAMPLE]
> ```rust
> #![windows_subsystem = "windows"]
> ```

r[runtime.windows_subsystem.syntax]
It uses the [MetaNameValueStr] syntax to specify the subsystem with a value of either
`console` or `windows`.
The `windows_subsystem` attribute uses the [MetaNameValueStr] syntax. Accepted values are `"console"` and `"windows"`.

r[runtime.windows_subsystem.allowed-positions]
The `windows_subsystem` attribute may only be applied to the crate root.

r[runtime.windows_subsystem.duplicates]
Only the first use of `windows_subsystem` is honored.

> [!NOTE]
> `rustc` currently lints against uses following the first. This may become a hard error in the future.

r[runtime.windows_subsystem.ignored]
This attribute is ignored on non-Windows targets, and for non-`bin` [crate types].
The `windows_subsystem` attribute is ignored on non-Windows targets and non-`bin` [crate types].

r[runtime.windows_subsystem.console]
The "console" subsystem is the default. If a console process is run from an
existing console then it will be attached to that console, otherwise a new
console window will be created.
The `"console"` subsystem is the default. If a console process is run from an existing console then it will be attached to that console; otherwise a new console window will be created.

r[runtime.windows_subsystem.windows]
The "windows" subsystem is commonly used by GUI applications that do not want to
display a console window on startup. It will run detached from any existing console.
The `"windows"` subsystem will run detached from any existing console.

```rust
#![windows_subsystem = "windows"]
```
> [!NOTE]
> The `"windows"` subsystem is commonly used by GUI applications that do not want to display a console window on startup.

[`GlobalAlloc`]: alloc::alloc::GlobalAlloc
[crate types]: linkage.md
Expand Down