Skip to content

Commit c56312b

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

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: src/beneath-std.md

+6-1
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

@@ -44,6 +47,7 @@ in the same format as C (aside from the exact integer types being used):
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;
@@ -78,6 +82,7 @@ compiler's name mangling too:
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)