Skip to content

Commit

Permalink
Auto merge of #3226 - ChrisDenton:std-no-legacy, r=JohnTitor
Browse files Browse the repository at this point in the history
Don't link `legacy_stdio_definitions` from std

std on windows-msvc does not use `printf` or `fprintf` so never needs the `legacy_stdio_definitions.lib` import library and will always work fine without it.
  • Loading branch information
bors committed Apr 26, 2023
2 parents 4c27d5d + 34866c1 commit 8a3a8be
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/windows/mod.rs
Expand Up @@ -278,13 +278,17 @@ impl ::Clone for fpos_t {
}

// Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860
#[cfg_attr(
all(windows, target_env = "msvc"),
link(name = "legacy_stdio_definitions")
)]
extern "C" {
pub fn printf(format: *const c_char, ...) -> ::c_int;
pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int;
cfg_if! {
if #[cfg(not(feature = "rustc-dep-of-std"))] {
#[cfg_attr(
all(windows, target_env = "msvc"),
link(name = "legacy_stdio_definitions")
)]
extern "C" {
pub fn printf(format: *const c_char, ...) -> ::c_int;
pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int;
}
}
}

extern "C" {
Expand Down

0 comments on commit 8a3a8be

Please sign in to comment.