From 2ec8995d01e8190d56220552538234215fa3d293 Mon Sep 17 00:00:00 2001 From: Tastaturtaste Date: Thu, 4 Aug 2022 01:10:32 +0200 Subject: [PATCH] Fix for https://github.com/rust-lang/libc/issues/2860 --- src/windows/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 08cba4edd094b..acb0de9895170 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -277,6 +277,16 @@ 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; +} + extern "C" { pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; @@ -319,8 +329,6 @@ extern "C" { pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); - pub fn printf(format: *const c_char, ...) -> ::c_int; - pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int; pub fn atoi(s: *const c_char) -> c_int; pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;