Sorting out variable conversion warnings ...
cmason
Posts: 123
How do you get the compiler to stop whining about this?:
sinSum[x] = sinSum[x] + intAddend[y] * -1
Generates "WARNING: Converting type [SINTEGER] to [INTEGER] "
I tried:
sinSum[x] = sinSum[x] + TYPE_CAST(intAddend[y] * -1)
And:
sinSum[x] = sinSum[x] + TYPE_CAST(intAddend[y]) * TYPE_CAST(-1)
The compiler seems to whine no matter what I try.
Thanks for looking...
sinSum[x] = sinSum[x] + intAddend[y] * -1
Generates "WARNING: Converting type [SINTEGER] to [INTEGER] "
I tried:
sinSum[x] = sinSum[x] + TYPE_CAST(intAddend[y] * -1)
And:
sinSum[x] = sinSum[x] + TYPE_CAST(intAddend[y]) * TYPE_CAST(-1)
The compiler seems to whine no matter what I try.
Thanks for looking...
0
Comments
The fact that you are multiplying intAddend by minus 1 implicitly converts it to an SINTEGER, and any operations on the result forces the result into an SINTEGER as well. There is a rule set to how internal typecasts are done for the purpose of operations, and not all of it is documented, so I have found it by far easier to make sure all my variables are of the same type inside an equation. If I need them to be something else later, I type_cast the *result* while assigning it to its final variable.
VOLATILE SINTEGER sinSum[]
VOLATILE INTEGER intAddend[]
Thanks "nickm".
I'm not sure why I didn't try that. Usually I stumble through how to apply TYPE_CAST. I cleaned a bunch of warnings up after reading a different tread addressing TYPE_CAST but the example I gave you just wouldn't go away.
It's funny that "sinSum[x] = sinSum[x] + TYPE_CAST(intAddend[y]) * TYPE_CAST(-1)" dosen't work...
yet "sinSum[x] = sinSum[x] + TYPE_CAST(intAddend[y]) * TYPE_CAST(25)" does.
I have gone back and converted INTEGERS (that didn't need to be) to SINTEGERS just to make the warnings go away. But then I would use those SINTEGERS elsewhere in my code and force new warnings, it seemed like would have to go back and convert more INTEGERS... spiraling out of control!
Maybe I should just drop INTEGERS all together and only use SINTEGERS in place of all INTEGERS that are not likley to exceed 32,768?!?!?
If you are going to need the sign at any point, that's not a bad solution.
FYI, SLONG actually has a problem in the compiler that is a bug. See this post I made in another thread about SLONG type casting warnings. It has been reported to AMX...