https://kotlinlang.org logo
p

phisch

06/27/2021, 6:52 PM
I have a project that builds to linux for x11 and wayland. Each of those need different cinterop library definitions. So i thought it's a good idea to split each c library into its own definition file, so i could cherry pick what i need for each target. Like i'd have one
xcb.def
(used for x11), one
cairo.def
(used for both x11 and wayland), and a
pango.def
(also used for both targets). The issue is that a part of the cairo library (which i will extract into its own def file), links against xcb. So if i create its own file for this, the package will be a different one, and in code, i end up with 2 interop types in different packages which are basically the same. So a function from the cairo package might require
cairo.xcb_visualtype_t
instead of a
xcb.xcb_visualtype_t
and i have no idea how to tell it that it should use the one from the xcb namespace instead. There is probably a really easy way to solve this, but i don't know how yet, and the documentations didn't push me in the right direction.
The only "easy" solution i could think of would be to use the same package name for each definition file. Like
backend
, and then both xcb and cairo would have it as
backend.xcb_visualtype_t
. I guess this would work as long as there are no conflicting functions in those libraries.
Yeah, putting all into one package works. But please let me know if there is a better way to handle this. (just in case someone has the same issues and conflicting functions in the libraries used)
6 Views