Skip to content

Commit

Permalink
Auto merge of #2861 - Tastaturtaste:master, r=Amanieu
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Aug 4, 2022
2 parents 431591a + 2ec8995 commit 12f0b20
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 12f0b20

Please sign in to comment.