Chapter 7. Warnings

Warnings give the programmer information about possible errors in qore code.

Warnings can be enabled using the -W command-line option (see Command-Line Parsing for more information) or by using the %enable-all-warnings or %enable-warning parse directives.

Note that parsing is done in two stages, so if a warning is enabled when the second stage of parsing begins, the warning can be generated anywhere in the source code. Parse directives are processed in the first stage of parsing. In other words, for warnings only raised in the second stage of parsing, it is not possible to turn on and turn off these warnings for specific code blocks within a section of text being parsed.

Table 7.1. Warnings

Warning Code

Description

duplicate-local-vars

This warning is raised when the same local variable is declared more than once within the same lexical scope.

warning-mask-unchanged

This warning is raised when a program tries to change the warning mask with parse options, but the warnings are locked.

unknown-warning

This warning is raised when a program tries to enable or disable an unknown warning.

undeclared-var

This warning is raised when a program uses a variable that has not been declared with my or our.

duplicate-global-vars

Raised when a program declares a global variable more than once.

unreachable-code

Raised when code is defined that can never be executed (for example, code following a return or thread_exit statement).