Skip to content

Commit

Permalink
Don't link legacy_stdio_definitions from std
Browse files Browse the repository at this point in the history
std on Windows does not use `printf` or `fprintf` so never needs the `legacy_stdio_definitions.lib` import library.
  • Loading branch information
ChrisDenton committed Apr 26, 2023
1 parent 5744793 commit 34866c1
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 34866c1

Please sign in to comment.