Skip to content

Commit 9384af4

Browse files
committed
Link examples to the correct libc when targeting Windows
1 parent 9c943bf commit 9384af4

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

example/alloc_example.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use alloc_system::System;
1111
#[global_allocator]
1212
static ALLOC: System = System;
1313

14-
#[link(name = "c")]
14+
#[cfg_attr(unix, link(name = "c"))]
15+
#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
1516
extern "C" {
1617
fn puts(s: *const u8) -> i32;
1718
}

example/mini_core.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ pub mod intrinsics {
532532
}
533533

534534
pub mod libc {
535-
#[cfg_attr(not(windows), link(name = "c"))]
536-
#[cfg_attr(windows, link(name = "msvcrt"))]
535+
#[cfg_attr(unix, link(name = "c"))]
536+
#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
537537
extern "C" {
538538
pub fn puts(s: *const i8) -> i32;
539539
pub fn printf(format: *const i8, ...) -> i32;

example/mod_bench.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![feature(start, box_syntax, core_intrinsics, lang_items)]
22
#![no_std]
33

4-
#[link(name = "c")]
4+
#[cfg_attr(unix, link(name = "c"))]
5+
#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
56
extern {}
67

78
#[panic_handler]

0 commit comments

Comments
 (0)