From c56312bba7c74b3db98bf2eb8a382ea9757c8a46 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 18 May 2024 20:14:40 -0400 Subject: [PATCH] cfg out the extern crate libc on Windows --- src/beneath-std.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/beneath-std.md b/src/beneath-std.md index 02a02bd7..e5582a36 100644 --- a/src/beneath-std.md +++ b/src/beneath-std.md @@ -19,7 +19,10 @@ Note that the default features have been disabled. This is a critical step - disabled.** Alternatively, we can use the unstable `rustc_private` private feature together -with an `extern crate libc;` declaration as shown in the examples below. +with an `extern crate libc;` declaration as shown in the examples below. Note that +windows-msvc targets do not require a libc, and correspondingly there is no `libc` +crate in their sysroot. We not need the `extern crate libc;` below, and having it +on a windows-msvc target would be a compile error. ## Writing an executable without `std` @@ -44,6 +47,7 @@ in the same format as C (aside from the exact integer types being used): extern crate unwind; // Pull in the system libc library for what crt0.o likely requires. +#[cfg(not(windows))] extern crate libc; use core::panic::PanicInfo; @@ -78,6 +82,7 @@ compiler's name mangling too: extern crate unwind; // Pull in the system libc library for what crt0.o likely requires. +#[cfg(not(windows))] extern crate libc; use core::ffi::{c_char, c_int};