Skip to content

Commit 10bb48d

Browse files
committed
Auto merge of #2861 - Tastaturtaste:master, r=Amanieu
Fix for #2860 This PR is intended to fix the issue #2860. As indicated in the issue, this fix requires linking against "legacy_stdio_definitions.lib", [which is only provided with Visual Studio >=15](https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp?view=msvc-170#libraries). I don't know how this could be checked conditionally at compile time though.
2 parents 7d55e38 + 2ec8995 commit 10bb48d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/windows/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,16 @@ impl ::Clone for fpos_t {
277277
}
278278
}
279279

280+
// 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;
288+
}
289+
280290
extern "C" {
281291
pub fn isalnum(c: c_int) -> c_int;
282292
pub fn isalpha(c: c_int) -> c_int;
@@ -319,8 +329,6 @@ extern "C" {
319329
pub fn feof(stream: *mut FILE) -> c_int;
320330
pub fn ferror(stream: *mut FILE) -> c_int;
321331
pub fn perror(s: *const c_char);
322-
pub fn printf(format: *const c_char, ...) -> ::c_int;
323-
pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int;
324332
pub fn atoi(s: *const c_char) -> c_int;
325333
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
326334
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;

0 commit comments

Comments
 (0)