https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

jdiaz

12/25/2019, 9:44 PM
Is it possible to share common code between native targets with CInterop working?
d

Dominaezzz

12/25/2019, 9:47 PM
Yes, you can create a common source set and create the same cinterop for each native target.
j

jdiaz

12/25/2019, 9:48 PM
I got the common sourceset but not too sure how could I do the cinterop
d

Dominaezzz

12/25/2019, 9:49 PM
Have you made your def file and referenced in gradle?
j

jdiaz

12/25/2019, 9:56 PM
I don't really want a custom cinterop but the pre-configured one like posix
I'm reading a file in native (macos right now) and wouldn't like to copypasta the same code for linux (fopen, memscoped... so on)
d

Dominaezzz

12/25/2019, 9:57 PM
Oh ohhhh
j

jdiaz

12/25/2019, 9:59 PM
https://pastebin.com/nyySRFZy this is the type of code I'd like to share between native targets
d

Dominaezzz

12/25/2019, 9:59 PM
You can have that code in the common code, it will build, compile and run as expected. The IDE will just make everything (C interop related) red because it's not smart enough yet.
j

jdiaz

12/25/2019, 10:03 PM
Aha! Then I'll wait for now. I don't really need linux and once it's smart enough I'll use it! If someone have the youtrack link, please. I'll upvote!
j

jdiaz

12/25/2019, 10:06 PM
Good then, really thank you!
d

Dominaezzz

12/25/2019, 10:29 PM
No problem!
2 Views