#cfg not working
Closed this issue · 7 comments
Hello,
I am using Rust nightly on Linux and I have GTK 3.12. I compiled with GTK_VERSION ?= GTK_3_12
in my Makefile and when I tried to create a gtk::Button::new_from_icon_name
I got an error it did not exist. When I commented out the
#[cfg(GTK_3_10)]
#[cfg(GTK_3_12)]
It worked fine.
I'm not sure if the #cfg
is working correctly?
Are you trying to build with Cargo? That unfortunately doesn't support passing --cfg
to rustc yet.
Discussing with the Rust people #cfg
is runtime not compile time, so #cfg
won't work for what it is intended too do (be an ifdef
) we will need to find an other solution as you will run into non exist errors with old GTK versions.
That's a bad news... I'll speak about it with @jeremyletang and try to find a solution. Maybe someone else had the same problem and solved it...
hi,
#cfg
attribute is conditional compilation, see this link: 6.3.7 Conditional compilation from the Rust manual.
I think the problem come from the way I use it.
Hrmmm, I was playing around on a GTK 3.4 OS and rgtk and it would not compile unless I removed everything with a #cfg
around it. It kept complaining about missing stuff from the GTK headers. Which led me to believe that #cfg
is run time compilation. Upon asking in the rust IRC channel I was informed that #cfg
is run time compilation, not compile time (ie not an #ifdef
).
I could have been informed wrong, but why would it not compile unless the parts that GTK 3.4 doesn't have were removed completed.
Hi dubcanada,
latest commit should have fixed compiling with different GTK target versions.
Please see README.md on how to set up your Cargo.toml.
I think this may be closed...
I confirm.