0
votes

I'm working on getting an app compatible with iPhone 6, and mostly have just run into type casting issues that need to be resolved. But no matter how I cast this one, I can't get the build to complete successfully.

inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength ){
    // N is set to 628 up above
    register uint32 j = 0;
    register int k = (N > seedLength ? N : seedLength);  // build fail on this line
    // do more stuff

I thought changing it to

register int k = (N > seedLength ? (int)N : (int)seedLength);

would work, but I still get the 'Implicit conversion loses integer precision: 'const uint32' (aka 'const unsigned long') to 'int' error. I'm pretty new to iOS development, so this could be something simple that I'm missing. Any tips?

1
What is the datatype of N? Why not change k to be uint32 instead of int? - rmaddy
N is just int type (public: enum{N = 624}). I've tried casting k as uint32 and it still complains about the implicit conversion. - SirDeimos
Just a guess, but do you need to cast the comparison as well as the two possible values: register int k = ((int)N > (int)seedLength ? (int)N : (int)seedLength); - pbasdf
I ended up getting it to work with the line that I thought would work, but the error message wasn't getting updated on build for some reason. As soon as I closed/reopened XCode, it built fine. - SirDeimos
register int k = static_cast<int>(N > seedLength ? N : seedLength); - sjdowling

1 Answers

0
votes

Cast all of the values to (int), not just the comparison.

register int k = ( (int)N > (int)seedLength ? (int)N : (int)seedLength);