slowtec/tokio-modbus

expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`

thy1037 opened this issue · 4 comments

When I add tokio-modbus as a dependencies, cargo build will failed.

Reproduction:

  1. cargo new a new project
  2. add tokio-modbus = "0.5.3" to Cargo.toml
  3. copy the example tcp-client code to main.rs
  4. run cargo build, and show:
   Compiling mio-serial v5.0.3
error[E0308]: mismatched types
   --> C:\Users\dell\.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\mio-serial-5.0.3\src\lib.rs:822:42
    |
822 |         let r = unsafe { SetCommTimeouts(handle, &mut timeouts) };
    |                          --------------- ^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
    |                          |
    |                          arguments to this function are incorrect
    |
    = note: expected raw pointer `*mut winapi::ctypes::c_void`
               found raw pointer `*mut std::ffi::c_void`
note: function defined here
   --> C:\Users\dell\.cargo\registry\src\mirrors.ustc.edu.cn-61ef6e0cd06fb9b8\winapi-0.3.9\src\um\commapi.rs:74:12
    |
74  |     pub fn SetCommTimeouts(
    |            ^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `mio-serial` due to previous error

Environment:
Win10
rustc 1.65.0 (897e37553 2022-11-02)
rustup 1.25.1 (bb60b1e89 2022-07-12)
x86_64-pc-windows-msvc

Probably caused by tokio-rs/tokio#5204.

Confirmed: https://github.com/slowtec/tokio-modbus/actions/runs/3647400977/jobs/6159588455

Please try to pin your tokio version to 1.22.0 until the incompatibilities have been resolved.

Confirmed: https://github.com/slowtec/tokio-modbus/actions/runs/3647400977/jobs/6159588455

Please try to pin your tokio version to 1.22.0 until the incompatibilities have been resolved.

Add tokio = {version = "=1.22.0", features = ["full"]} to Cargo.toml, the incompatibilities can be resolved.

But running has problem, create a new issue #138

Fixed by #139.