Skip to content

Commit 34866c1

Browse files
committed
Don't link legacy_stdio_definitions from std
std on Windows does not use `printf` or `fprintf` so never needs the `legacy_stdio_definitions.lib` import library.
1 parent 5744793 commit 34866c1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/windows/mod.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,17 @@ impl ::Clone for fpos_t {
278278
}
279279

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

290294
extern "C" {

0 commit comments

Comments
 (0)