Skip to content

Commit 6599a69

Browse files
committed
Use CONSOLE subsystem entry points; update link
1 parent 8d31229 commit 6599a69

File tree

1 file changed

+6
-4
lines changed
  • blog/content/second-edition/posts/01-freestanding-rust-binary

1 file changed

+6
-4
lines changed

blog/content/second-edition/posts/01-freestanding-rust-binary/index.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,18 @@ One way to pass linker attributes via cargo is the `cargo rustc` command. The co
261261
With this command, our crate finally builds as a freestanding executable!
262262

263263
#### Windows
264-
On Windows, the linker requires two entry points: `WinMain` and `WinMainCRTStartup`, [depending on the used subsystem](https://msdn.microsoft.com/en-us/library/f9t8842e.aspx). Like on Linux, we overwrite the entry points by defining `no_mangle` functions:
264+
On Windows, the linker requires two entry points [depending on the used subsystem]. For the `CONSOLE` subsystem, we need a function called `mainCRTStartup`, which calls a function called `main`. Like on Linux, we overwrite the entry points by defining `no_mangle` functions:
265+
266+
[depending on the used subsystem]: https://docs.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol
265267

266268
```rust
267269
#[no_mangle]
268-
pub extern fn WinMainCRTStartup() -> ! {
269-
WinMain();
270+
pub extern fn mainCRTStartup() -> ! {
271+
main();
270272
}
271273

272274
#[no_mangle]
273-
pub extern fn WinMain() -> ! {
275+
pub extern fn main() -> ! {
274276
loop {}
275277
}
276278
```

0 commit comments

Comments
 (0)