https://kotlinlang.org logo
k

kpgalligan

09/21/2021, 3:42 PM
Running into a cinterop issue.
typedef struct
produces a kotlin definition with package
cnames.structs
. I don't think it's possible to change the package used, or I can't find a way in the docs. It works OK on linux, but we have a name collision with a darwin platform struct. It doesn't make a lot of sense to me. They have the same name, but when I navigate to the type in the IDE, the darwin platform type has a different package. In our code, we import `import cnames.structs.JSContext`and that works for target
linuxX64
but not for
iosX64
(
macosX64
, etc). Any quick thoughts before I start deep diving? Thanks in advance...
In the header it looks like this `typedef struct JSContext JSContext;`with the actual struct defined in the c file. That appears to conflict with JSContext from JavaScriptCore (https://developer.apple.com/documentation/javascriptcore/jscontext). It seems odd because they appear to have different packages.
n

napperley

09/21/2021, 8:14 PM
That sounds more like a Apple platform support issue. With a C library the package name (is flat and doesn't use the reverse FQDN naming scheme) can be set in the def file, eg:
Copy code
package = pahoMqtt
j

jw

09/22/2021, 3:20 AM
We already do that. These types are in
cnames.struct
, not our package.
k

kpgalligan

09/22/2021, 6:59 PM
I don't really see it documented anywhere, but it seems like structs all go to that package regardless of config, and it's got weird resolution (names conflicted in a surprising way). quick and dirty workaround was changing the typedef name, but plan to dig into it more.
2 Views