From f7cf709062672b8ff3f91b54683d6452c4a0d962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 6 Jul 2019 02:21:50 +0300 Subject: [PATCH] tutorials/basic-tutorial-5: Make sure to only declare GDK C functions for the right platform Otherwise linking might fail depending on the compiler flags if the linker does not remove all references to unused code. --- tutorials/src/bin/basic-tutorial-5.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tutorials/src/bin/basic-tutorial-5.rs b/tutorials/src/bin/basic-tutorial-5.rs index a34bb96ae..0adcdec0b 100644 --- a/tutorials/src/bin/basic-tutorial-5.rs +++ b/tutorials/src/bin/basic-tutorial-5.rs @@ -215,7 +215,8 @@ mod tutorial5 { } let display_type_name = gdk_window.get_display().get_type().name(); - if cfg!(feature = "tutorial5-x11") { + #[cfg(all(target_os = "linux", feature = "tutorial5-x11"))] + { // Check if we're using X11 or ... if display_type_name == "GdkX11Display" { extern "C" { @@ -233,7 +234,9 @@ mod tutorial5 { println!("Add support for display type '{}'", display_type_name); process::exit(-1); } - } else if cfg!(feature = "tutorial5-quartz") { + } + #[cfg(all(target_os = "macos", feature = "tutorial5-quartz"))] + { if display_type_name == "GdkQuartzDisplay" { extern "C" { pub fn gdk_quartz_window_get_nsview(