Kode/kincmake

Compile errors using thx.core library on iOS

Closed this issue · 5 comments

Hi Robert,

In our project i require a BigInt. So i googled and found one in https://github.com/fponticelli/thx.core.
So i included it and it's working fine except on iOS.

import thx.BigInt;

class Main {
    public static function main() {
        var n1 = BigInt.fromString('123456789012345678901234567890');
        var n2 = BigInt.fromInt(1);
        var r = n1 + n2;
        trace('$r');
    }
}

Using thx.core in a c++ only project (haxe -main Main -lib thx.core -cpp ./) works fine.

Using this code in a Kha project fails in the generated Tuple0_Impl_.h everywhere Nil or nil is used. (I'm not sure why tuple even ends up in the cpp code, as there doesn't seem to be a dependency to it in the BigInt stuff i'm using).

thx.core contains a Nil value ...

package thx;
enum Nil { nil; }

... and this seems the clash with objective-c's nil value.

For testing i renamed all Nil and nil in the generated cpp code and then it compiles.

Now i'm not sure on how to proceed best.

    1. fix the xcode project, to not use "objective-c stuff" when compiling cpp code (i'm not sure thats possible, or how to do it)
    1. just rip out the neccessary code and include it in our project (i don't like it, but would be kinda ok with it and will go with it for the time being)
    1. fork thx.core and rename the nil stuff (i don't like it)
    1. tell fponticell (dev of thx.core) about the problem (i don't think it's his issue at all though)
    1. ...?

Strange thing is, it does compile on OSX (and that uses mixed *.mm / *.cpp files as well), so i have hope we can do something to make 1) come true 😅

Found the dependency chain: BigInt -> String -> Arrays -> Functions -> Validation -> Either -> Tuple
while trying to copy only the neccessary code. Will go with the renaming then i guess.

And the same problem for the tink library (tink.core.Pair.nil())

I think I know where that nil comes from. Might become messy to remove that but I'll try.

Nothing messy about it, just don't include objective-c headers for c++ code 😛

Ah, what a mess :)