Is it possible to share common code between native...
# multiplatform
j
Is it possible to share common code between native targets with CInterop working?
d
Yes, you can create a common source set and create the same cinterop for each native target.
j
I got the common sourceset but not too sure how could I do the cinterop
d
Have you made your def file and referenced in gradle?
j
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
Oh ohhhh
j
https://pastebin.com/nyySRFZy this is the type of code I'd like to share between native targets
d
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
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
Good then, really thank you!
d
No problem!