Skip to content

Commit

Permalink
fix: compile error on Windows because of macro WIN32
Browse files Browse the repository at this point in the history
  • Loading branch information
chiichen committed Nov 30, 2024
1 parent 9083386 commit 2276942
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libvnc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bindgen = "0.70.0"
cc = "1.0.95"
pkg-config = "0.3.30"
cmake = "0.1.52"
which = "7.0.0"
# which = "7.0.0"

[features]
default = []
Expand Down
14 changes: 11 additions & 3 deletions libvnc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ fn bindgen_vncserver() {
);
}
} else if target_os == "windows" {
config.generator("Ninja");
config.no_default_flags(true);
// Is it necessary?
// config.define(
// "CMAKE_TOOLCHAIN_FILE",
// which::which("vcpkg")
// .expect("Install vcpkg and make sure it can be found in current environment")
// .parent()
// .unwrap()
// .join("scripts/buildsystems/vcpkg.cmake"),
// );
config.define("WITH_OPENSSL", "OFF");
config.define("WITH_GNUTLS", "OFF");
config.define("WITH_GCRYPT", "OFF");
config.cflag("-DWIN32"); //TODO I think it's a bug in libvncserver. It's expected to use _WIN32 macro to determine whether it's on Windows platform. However, it uses WIN32 instead.@see https://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c
} else if target_os == "android" {
panic!("unsupported build target {}", target_os)
}
Expand All @@ -83,7 +91,7 @@ fn bindgen_vncserver() {
.clang_args([
format!("-I{}/{}", dst.display(), "include"),
#[cfg(target_os = "windows")]
r#"-DWIN32"#.to_string(), //TODO I think it's a bug in libvncserver. It's expected to use _WIN32 macro to determine whether it's on Windows platform. However, it uses WIN32 instead.@see https://stackoverflow.com/questions/662084/whats-the-difference-between-the-win32-and-win32-defines-in-c
r#"-DWIN32"#.to_string(), // As Above
])
.generate()
.expect("unable to generate rfb bindings");
Expand Down

0 comments on commit 2276942

Please sign in to comment.