Hey there I have a kotlin MPP (android and ios) an...
# kotlin-native
c
Hey there I have a kotlin MPP (android and ios) and I have
ios32
and
ios64
presets. And some methods thatI use have a different signatures in 32 where it uses
Int
versus 64 where it uses
Long
. Those method are ios specific only. If I declare the same method twice (in 32 and 64 source set) then obviously I get a multiple definition error. Is there a way to deal with this where I dont need to have `expected`/`actual` because android would have no need for it and therefore 'fake' implementation?
o
Use
convert
when calling method in question and just share the code
c
memcpy(nsData.refTo(0), bytes, size.toULong())
that is for 64 and
memcpy(nsData.refTo(0), bytes, size.toUInt())
that is for 32
Not too sure how to use
convert
since it only convert from
Long
and
Double
to
String
. Even suing `actual`/`expected` creates :
overload resolution ambiguity
error.
o
use
size.convert()
as an argument
s
this is why need conditional compilation with
#if
it simplify stuff by a lot
c
it did work thanks.
@sksk I feel like convert is more elegant than
#if
as it avoid duplication of code. You just have one extension method to call. better than duplicating the whole line. At least for numbers it is better I reckon.
s
convert comes probably with some overhead, #if is FREE
c
Very true, that's a fair point.
o
Nope,
convert
is compile-time intrinsic and is free
c
Brilliant !