$warn
{$warn} is a local compiler directive controlling emission of certain messages during compile-time. Messages do not necessarily have to be warnings, but can be messages of any kind. The directive may also promote specific messages to errors.
The (local) compiler directives {$warnings on} and {$warnings off} may turn on or off emission of all warnings all together.
usage
{$warn} requires a message label and a treatment option as arguments, like this:
{$warn 3250 off}The numeric message label can be retrieved during compilation with the -vq option supplied on the command-line (verbosity: show message numbers). Some messages and groups of messages have an alias, too, which can be seen in the table below.
Beside {$warn 3019 on} or {$warn 3019 off} and the shorthand notation {$warn 3019 +} and {$warn 3019 -} respectively, {$warn} may be used to promote messages to errors. {$warn symbol_experimental error} will make all, if any, hints concerning experimental symbols become (non-fatal) errors. Depending on the selected error treatment, the compiler may stop compiling or continue, unless a threshold of errors has been reached.
Note, demoting messages to errors is not possible. A {$fatal} error will always be fatal.
message labels
FPC messages (excerpt)
index
alias
situations triggering the message
02024
- there is a custom defined
{$warning}
02077
- the directive
{$minStackSize}is used, but not supported on the current OS
02078
- the directive
{$maxStackSize}is used, but not supported on the current OS
03018
- a
constructoris not defined atpublicvisibility level
03019
- a
destructoris not defined atpublicvisibility level
03177
- a
recordinitialization does not define values for all fields
03211
implicit_variants
- the
variantsunit is required, but has not yet been loaded
03250
- a virtual method is overridden with lower visibility
04044
- a comparison might be always
false(disjunct ranges)
04045
- a comparison might be always
true(disjunct ranges)
04046
constructing_abstract
- constructing an instance of a class with abstract methods
04056
- a pointer to ordinal conversion is not portable
04090
zero_nil_compat
- converting
0to nil (integer to pointer)
04104
implicit_string_cast
- implicit string type conversion
04105
implicit_string_cast_loss
- implicit string type conversion with potential data loss
04106
explicit_string_cast
- explicit string type conversion
04107
explicit_string_cast_loss
- explicit string type conversion with potential data loss
04108
cvt_narrowing_string_lost
- Unicode constant cast with potential data loss
04116
intf_raise_visibility
- the interface defines a broader visibility for a method
04122
constructing_abstract
- constructing an instance of an abstract class
05023
- a
unitis imported, but not used (except units containinginitialization/finalizationcode)
05024
- a routine parameter remains unused
05033
no_retval
- no (for the compiler obvious) assignment to a function’s return value
05036
- a variable which might not yet have been initialized is used
05043
symbol_deprecated
- a symbol with the
deprecatedhint (no deprecation message defined) is used
05044
symbol_platform
- a symbol with the
platformhint is used
05055
symbol_unimplemented
- a symbol with the
unimplementedhint is used
05059
- inside a function definition its result variable’s value is used, before it has been initialized
05063
symbol_experimental
- a symbol with the
experimentalhint is used
05065
symbol_library
- a library symbol is used
05066
symbol_deprecated
- a symbol with the
deprecatedhint is used and a custom deprecation notice has been defined
05073
- a
private propertyremains unused
05074
unit_deprecated
- a unit with the
deprecatedhint (without a custom deprecation message supplied) is used
05075
unit_deprecated
- a unit with the
deprecatedhint is used and a custom deprecation notice has been defined
05076
unit_platform
- a unit with the
platformhint is used
05077
unit_library
- [to be explained]
05078
unit_unimplemented
- a unit with the
unimplementedhint is used
05079
unit_experimental
- a unit with the
experimentalhint is used
06018
- the compiler has determined there is, or might be, unreachable code
07104
- register indirect addressing with
ebpis used in conjunction with a negative offset
Note, some aliases identify multiple messages.
see also
- § “
$WARN: Control emission of warnings” in the Free Pascal programmer’s guide - {$message}
- Turn warnings and hints on or off
From the Free Pascal wiki, page "$warn", as it stood on 2022-09-07 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.