ZBasic Language Reference
161
ZBasic Microcontrollers
#pragma warning( <warning id> : <disposition> )
The <warning id> element is either a numeric value (included as part of the warning message) or one
of the mnemonic warning identifiers used with the warn option. The <disposition> element must be
one of the keywords On, Off or Default, the effect of which is to enable the warning, disable the
warning or set it to the default state.
An example of the use of of the warning directive to disable a warning for useless code is shown below.
Dim b as Byte
Dim i as Integer
Sub Main()
b = 3
#pragma warning(7 : Off)
If (b > 5) Then
i = 100
ElseIf (b <= 5) Then
i = 10
End If
#pragma warning(7 : On)
b = 25
End Sub
Because of the immediately preceding assignment, the compiler can deduce the Boolean value of the
conditions in both the If and ElseIf statements and will issue a useless-code warning indicating that that
those conditions are always false. The first warning directive disables that warning and the second one
unconditionally enables it. Often, it is undesirable to unconditionally enable a warning after disabling it as
was done in this example. To avoid enabling a warning that was not previously enabled, two variations of
the warning directive are provided to save the current set of enabled warnings (push) and restore them
afterward (pop) instead of unconditionally re-enabling a warning. The syntax for the push and pop
warning directives is illustrated in the modified example below.
Dim b as Byte
Dim i as Integer
Sub Main()
b = 3
#pragma warning(push)
#pragma warning(7 : Off)
If (b > 5) Then
i = 100
ElseIf (b <= 5) Then
i = 10
End If
#pragma warning(pop)
b = 25
End Sub
Note that it is permissible to combine two or more warning directives by separating the warning
specifications using a semicolon. For example:
#pragma warning(push; 7:Off; unused-param:On)
10.3.2 Internal Errors
The compiler may, in unusual circumstances, generate an Internal Error message. This will happen when
it encounters a situation where inconsistencies in internal data structures arise that prevent continued
operation. If you encounter an internal error or a program fault, please report it so that it can be
investigated to see why the problem occurred. If possible, construct the smallest possible program that
still exhibits the problem and submit that program along with the error report. In some cases, you may be
|