spin2cpp incorrect placement of decrement operator
SRLM
Posts: 5,045
From this source code:
spin2cpp generates this C++ code (with linebreaks added for readability):
I get the following error:
The correct solution is two negation operators or none.
I'm using spin2cpp version 1.04 from the propgcc version alpha_v1_9_0_2042 on Ubuntu 13.04.
PUB ReadDelta(EncID): DeltaPos ''Read delta position (relative position value since last time read) of EncID. DeltaPos := 0 + -(EncID < TotDelta) * -long[Pos][TotEnc+EncID] + (long[Pos][TotEnc+EncID] := long[Pos][EncID])
spin2cpp generates this C++ code (with linebreaks added for readability):
int32_t quadrature_encoder::Readdelta(int32_t Encid) { int32_t Deltapos = 0; Deltapos = (0 + (([b]--[/b](Encid < Totdelta)) * (-((int32_t *)Pos)[((*(int32_t *)&dat[196]) + Encid)]))) + (((int32_t *)Pos)[((*(int32_t *)&dat[196]) + Encid)] = ((int32_t *)Pos)[Encid]); return Deltapos; }
I get the following error:
quadrature_encoder.cpp:57:41: error: lvalue required as decrement operand
The correct solution is two negation operators or none.
I'm using spin2cpp version 1.04 from the propgcc version alpha_v1_9_0_2042 on Ubuntu 13.04.
Comments
That's better than my solution: change the negation in the spin to a *-1