Sign in Join
Wiki copytemporary

Revision 3 of 3, by Kai Burghardt on 9-7-2022. The page as it is now.

$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:

pascal
{$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

02077

02078

03018

03019

03177

03211

implicit_variants

03250

04044

04045

04046

constructing_abstract

04056

04090

zero_nil_compat

04104

implicit_string_cast

04105

implicit_string_cast_loss

04106

explicit_string_cast

04107

explicit_string_cast_loss

04108

cvt_narrowing_string_lost

04116

intf_raise_visibility

04122

constructing_abstract

05023

05024

05033

no_retval

05036

05043

symbol_deprecated

05044

symbol_platform

05055

symbol_unimplemented

05059

05063

symbol_experimental

05065

symbol_library

05066

symbol_deprecated

05073

05074

unit_deprecated

05075

unit_deprecated

05076

unit_platform

05077

unit_library

05078

unit_unimplemented

05079

unit_experimental

06018

07104

Note, some aliases identify multiple messages.

see also


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.