Compiler Warnings
Overview
Compiler Warnings provide compile-time warnings for:
- Ambiguous functions
- Unicode unsafe commands
- Obsolete commands
- Obsolete global functions
- Use of the Indicate command instead of the Move command
- Use of “Local” in commands to define local variables
- Use of “public” or "private" in property commands
- Obsolete classes
- Inclusion and use of obsolete packages (raised when a package is used)
Warnings are just that – warnings. A project with warnings will run just fine.
Showing warnings can be enabled and disabled at the project level. At a more advanced level, you can also control warnings at the file or code level. The Studio shows the warnings in the output panel, making it easy to jump to the code in question.
Project Level Warnings
The Project Properties dialog has a new checkbox to Suppress Compiler Warnings.
Controlling Warnings at File or Code Level
The #WARNING command causes the compiler to output a warning. This is non-fatal, and the application will compile. The syntax is:
#warning ErrorNum "error text"
...just like the #error command.
You can use this new compiler command in your code to add your own warnings.
Commands to Control Warnings
There are two commands to control the behavior of various warnings:
CompilerWarnings Off|On|Suspend|Restart
This lets you control the entire warning system:
- Off – disables compiler warnings until they are re-enabled
- On – re-enables compiler warnings
- Suspend – disables compiler warnings until the end of the current file
- Restart – unconditionally turns compiler warnings back on
The warning system allows these commands to be nested. Each level of nesting increments an internal warnings-off counter, which will not be re-enabled until that count goes to 0. Think of it as Lock/Unlock.
CompilerLevelWarning All | AmbiguousFunctions | General | IfExp | IfLine | Item | Unicode On | Off
This is an advanced command that gives you some control over how strict your warning checking should be. By default, AmbiguousFunctions, General, and Unicode are On, while IfExp, IfLine, and Item are Off. Not all compiler warnings are optional like this; warnings that are borderline errors (like the use of ambiguous functions) can only be turned off if warnings are turned off (with the CompilerWarnings command or the Suppress Compiler Warning project property).
- AmbiguousFunctions – raises warnings
- IfExp – raises warnings when
if/else/caseuses old style “if x eq y” type of syntax instead of “if (x=y)” - IfLine – raises warnings when
if/else/caseis used in a single line - Item – raises warnings when the
Itemkeyword is used. It is never needed, but there is nothing wrong with using it - All – turns all extended warnings on. If you want the strictest warnings, just add this line to the top of your code:
CompilerLevelWarning All On