Skip to content

Commit 74df978

Browse files
committed
cfg out the extern crate libc on Windows
1 parent 0d5f884 commit 74df978

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: src/beneath-std.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ Note that the default features have been disabled. This is a critical step -
1919
disabled.**
2020

2121
Alternatively, 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 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)]
4447
extern crate unwind;
4548

4649
// Pull in the system libc library for what crt0.o likely requires.
50+
#[cfg(not(windows))]
4751
extern crate libc;
4852

4953
use 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)]
7882
extern crate unwind;
7983

8084
// Pull in the system libc library for what crt0.o likely requires.
85+
#[cfg(not(windows))]
8186
extern crate libc;
8287

8388
use core::ffi::{c_char, c_int};

0 commit comments

Comments
 (0)