@@ -19,7 +19,10 @@ Note that the default features have been disabled. This is a critical step -
19
19
disabled.**
20
20
21
21
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.
23
26
24
27
## Writing an executable without ` std `
25
28
@@ -39,11 +42,12 @@ in the same format as C (aside from the exact integer types being used):
39
42
#![allow(internal_features)]
40
43
#![no_std]
41
44
42
- // Necessary for `panic = "unwind"` builds on some platforms.
45
+ // Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
43
46
#![feature(panic_unwind)]
44
47
extern crate unwind;
45
48
46
49
// Pull in the system libc library for what crt0.o likely requires.
50
+ #[cfg(not(windows))]
47
51
extern crate libc;
48
52
49
53
use core :: panic :: PanicInfo ;
@@ -73,11 +77,12 @@ compiler's name mangling too:
73
77
#![no_std]
74
78
#![no_main]
75
79
76
- // Necessary for `panic = "unwind"` builds on some platforms.
80
+ // Necessary for `panic = "unwind"` builds on cfg(unix) platforms.
77
81
#![feature(panic_unwind)]
78
82
extern crate unwind;
79
83
80
84
// Pull in the system libc library for what crt0.o likely requires.
85
+ #[cfg(not(windows))]
81
86
extern crate libc;
82
87
83
88
use core :: ffi :: {c_char, c_int};
0 commit comments