@@ -19,7 +19,10 @@ Note that the default features have been disabled. This is a critical step -
1919disabled.**
2020
2121Alternatively, we can use the unstable ` rustc_private ` private feature together
22- with an ` extern crate libc; ` declaration as shown in the examples below.
22+ with an ` extern crate libc; ` declaration as shown in the examples below. Note that
23+ windows-msvc targets do not require a libc, and correspondingly there is no ` libc `
24+ crate in their sysroot. We do not need the ` extern crate libc; ` below, and having it
25+ on a windows-msvc target would be a compile error.
2326
2427## Writing an executable without ` std `
2528
@@ -39,11 +42,12 @@ in the same format as C (aside from the exact integer types being used):
3942#![allow(internal_features)]
4043#![no_std]
4144
42- // Necessary for `panic = "unwind"` builds on some platforms.
45+ // Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
4346#![feature(panic_unwind)]
4447extern crate unwind;
4548
4649// Pull in the system libc library for what crt0.o likely requires.
50+ #[cfg(not(windows))]
4751extern crate libc;
4852
4953use core :: panic :: PanicInfo ;
@@ -73,11 +77,12 @@ compiler's name mangling too:
7377#![no_std]
7478#![no_main]
7579
76- // Necessary for `panic = "unwind"` builds on some platforms.
80+ // Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
7781#![feature(panic_unwind)]
7882extern crate unwind;
7983
8084// Pull in the system libc library for what crt0.o likely requires.
85+ #[cfg(not(windows))]
8186extern crate libc;
8287
8388use core :: ffi :: {c_char, c_int};
0 commit comments