spin2cpp Byte and ~ Error
SRLM
Posts: 5,045
When converting the read_pulse_widths from the Eddie project I get the following error:
It looks like the problem code is
And the spin source:
read_pulse_widths.cpp:40:11: warning: promoted ~unsigned is always non-zero [-Wsign-compare]
It looks like the problem code is
uint8_t Cog;
int32_t read_pulse_widths::Stop(void) { if (~Cog) { cogstop(Cog); } return 0; }
And the spin source:
VAR byte cog PUB Stop 'Stop the currently running cog, if any if !cog cogstop(cog)
Comments
It appears that there's an error in the original Spin code. The normal practice is to set Cog to the return value of cognew plus 1, and to test Cog for a non-zero value when doing a cogstop. The logic in the current Spin code is incorrect.
Oops. You're right: the spin code does have an error. I'm making a list of the bugs in Eddie so I'll be sure to add that one. Thanks for catching it.