From 6599a6935fca6939f9af968645f5e4d850c78a0d Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 14 Mar 2018 18:22:13 +0100 Subject: [PATCH] Use CONSOLE subsystem entry points; update link --- .../posts/01-freestanding-rust-binary/index.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/blog/content/second-edition/posts/01-freestanding-rust-binary/index.md b/blog/content/second-edition/posts/01-freestanding-rust-binary/index.md index c8fcda48..9425c693 100644 --- a/blog/content/second-edition/posts/01-freestanding-rust-binary/index.md +++ b/blog/content/second-edition/posts/01-freestanding-rust-binary/index.md @@ -261,16 +261,18 @@ One way to pass linker attributes via cargo is the `cargo rustc` command. The co With this command, our crate finally builds as a freestanding executable! #### Windows -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: +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: + +[depending on the used subsystem]: https://docs.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol ```rust #[no_mangle] -pub extern fn WinMainCRTStartup() -> ! { - WinMain(); +pub extern fn mainCRTStartup() -> ! { + main(); } #[no_mangle] -pub extern fn WinMain() -> ! { +pub extern fn main() -> ! { loop {} } ```