-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't link legacy_stdio_definitions
from std
#3226
Conversation
r? @JohnTitor (rustbot has picked a reviewer for you, use r? to override) |
std on Windows does not use `printf` or `fprintf` so never needs the `legacy_stdio_definitions.lib` import library.
405c98b
to
34866c1
Compare
@bors r+ |
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; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; | |
} | |
} | |
#[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; | |
} |
nit: no need to use cfg_if!
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was what I originally did. but the style checker complained.
☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14 |
Which version will update? Now, I using "rustc 1.69.0 (84c898d65 2023-04-16)". Is it the latest version? |
std on windows-msvc does not use
printf
orfprintf
so never needs thelegacy_stdio_definitions.lib
import library and will always work fine without it.