Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8f5330e

Browse files
committed
Fix mini_core printf linking on windows
Link against legacy_stdio_definitions on windows which provides printf as a linkable symbol.
1 parent 46fa744 commit 8f5330e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

example/mini_core.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,19 @@ pub mod intrinsics {
575575
}
576576

577577
pub mod libc {
578+
// With the new Universal CRT, msvc has switched to all the printf functions being inline wrapper
579+
// functions. legacy_stdio_definitions.lib which provides the printf wrapper functions as normal
580+
// symbols to link against.
581+
#[cfg_attr(unix, link(name = "c"))]
582+
#[cfg_attr(target_env="msvc", link(name="legacy_stdio_definitions"))]
583+
extern "C" {
584+
pub fn printf(format: *const i8, ...) -> i32;
585+
}
586+
578587
#[cfg_attr(unix, link(name = "c"))]
579588
#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
580589
extern "C" {
581590
pub fn puts(s: *const i8) -> i32;
582-
pub fn printf(format: *const i8, ...) -> i32;
583591
pub fn malloc(size: usize) -> *mut u8;
584592
pub fn free(ptr: *mut u8);
585593
pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);

0 commit comments

Comments
 (0)