Skip to content

Support sprintf/snprintf and sscanf on windows #4995

@ColinPitrat

Description

@ColinPitrat

I'm working on progressively migrating an existing code base from C to Rust. This code base is multi-platform and needs to build on Windows too.

In C code, there were some #define snprintf _snprintf for windows.

In Rust code, when translating a snprintf using libc, it works fine on Linux but it doesn't build on Windows:

12 | use libc::{c_char, c_int, c_void, fprintf, free, malloc, memcpy, size_t, snprintf, sscanf, strcmp, strlen, isprint};
   |                                                                          ^^^^^^^^  ^^^^^^ no `sscanf` in the root
   |                                                                          |
   |                                                                          no `snprintf` in the root
   |                                                                          help: a similar name exists in the module: `printf`

Would it be possible to make sprintf, snprintf and sscanf available on Windows?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions