Back end error - 'else' without a previous 'if'
Posted: 07 October 2011, 17:49 PM
Compiling under v3.3 for a ZX24n, I get a back end build error:
Which is the following in ZBasic:
You'll notice that the conditional compilation directive doesn't encapsulate the 'Case Else'. In this particular instance, none of the conditional code is being used, leaving a Select Case with only the Case Else. While I understand what's happening here, I wonder if there's another way to for the compiler to handle the error before it get's to the back end.
As an aside, the IDE highlights the corrosponding line number of ZBasic code, in this case 176, when in actuality it is referring to the C code line 176. Perhaps this could be changed to point to the last line in the module, to indicate that the error is outside the realm of that module?
-DK
Which corrolates to the last else statement in the following C code:Compiler wrote: HoverGauge.c: In function 'zf_Main':
HoverGauge.c:176: error: 'else' without a previous 'if'
make: *** [HoverGauge.o] Error 1
make: Leaving directory `S:/ZBasic Code/zxTempDir/Hover'
Error: one or more errors occurred in the back-end build process for "Hover.zxb"
Code: Select all
zf_Main(void)
{
mzf_RunOnce();
while (1)
{
for (mzv_n = 1; mzv_n <= 6; mzv_n++)
{
if ((int16_t)progMemReadWord(PROG_MEM((uint8_t *)&zv_Alarm + ((uint16_t)mzv_n * 2) + 65534)) <= zv_Temp[mzv_n - 1])
{
mzf_CharliePlex(2 * mzv_n);
persistWriteByte(&zv_Mode, mzv_n);
zv_AlarmCondition = ZX_TRUE;
}
else if (persistReadByte(&zv_Mode) == mzv_n)
{
mzf_CharliePlex((2 * mzv_n) - 1);
zv_AlarmCondition = ZX_FALSE;
}
else
{
mzf_CharliePlex(mzv_n - mzv_n);
zv_AlarmCondition = ZX_FALSE;
}
}
{
uint8_t _zv_selectValTemp07;
_zv_selectValTemp07 = persistReadByte(&zv_Mode);
else
{
persistWriteByte(&zv_Mode, 1);
}
}
}
}
Code: Select all
Public Sub Main()
Call RunOnce()
Do
For n = 1 to MaxMode
If Alarm(n) <= Temp(n) Then 'I think this is wrong...
Call CharliePlex(n*2) 'Turn on one of the red LED's
Mode = n 'and display the value
AlarmCondition = True 'Set the alarm flag
ElseIf Mode = n Then
Call CharliePlex(n*2-1) 'turn on one of the green LED's
AlarmCondition = False 'clear the alarm flag
Else
Call CharliePlex(n-n) 'Turn them off
AlarmCondition = False 'clear the alarm flag
End If
Next n
Select Case Mode
#IfDef TempInstalled
Case 1 to 4 'tempuratures
Call UpdateDisplay(Temp(Mode), PauseDisplay)
#IfDef GPSEnabled
Call RememberSpeed()
#EndIf
#IfDef DebugEnable
Debug.Print(Temp(Mode))
Call Sleep(0.1)
#EndIf
#EndIf
#IfDef GPSInstalled
Case 5 'GPS Speed
Call UpdateDisplay(GetSpeed(), PauseDisplay)
Call RememberSpeed()
#IfDef DebugEnable
Debug.Print(GetSpeed())
Call Sleep(0.1)
#EndIf
Case 6 'GPS Course
Call UpdateDisplay(GetCourse(), PauseDisplay)
Call RememberSpeed()
#IfDef DebugEnable
Debug.Print(GetCourse())
Call Sleep(0.1)
#EndIf
#EndIf
Case Else
Mode = 1
End Select
Loop
End Sub
You'll notice that the conditional compilation directive doesn't encapsulate the 'Case Else'. In this particular instance, none of the conditional code is being used, leaving a Select Case with only the Case Else. While I understand what's happening here, I wonder if there's another way to for the compiler to handle the error before it get's to the back end.
As an aside, the IDE highlights the corrosponding line number of ZBasic code, in this case 176, when in actuality it is referring to the C code line 176. Perhaps this could be changed to point to the last line in the module, to indicate that the error is outside the realm of that module?
-DK