AltF02 / x11-rs

Rust bindings for X11 libraries
https://docs.rs/x11
MIT License
206 stars 66 forks source link

Potential solution to older library versions with missing symbols #87

Open ghost opened 6 years ago

ghost commented 6 years ago

When gl_generator's StructGenerator attempts to load a missing function, it doesn't fail like x11-dl currently does. Instead, it replaces the function with a panic wrapper with the same signature. This way a single missing function doesn't prevent the entire library from loading. I propose that we do the same thing in x11-dl. This would make the Xrandr_2_2_0 struct in old_xrandr.rs obsolete, and it would prevent similar situations from happening in the future (whether they're likely to happen or not). In addition, a function can be added to check by name whether a symbol is available. If desired, I may have time to implement this some time in the next week.

Background: x11-dl structures represent the public symbols exported by a shared object (like XOpenDisplay from libX11.so.6 in a struct called Xlib). If the library on the user's machine is missing even one of these symbols, the entire struct completely fails to initialize. IIRC, this happened on debian sid, making x11-dl completely unusable on such systems.

erlepereira commented 6 years ago

I like this idea, make sense. Will look into this myself too, have not tried this against a debian sid base yet, still looking around things.