[fpc-devel] Breaking change in FPC 2.6.1

Mattias Gaertner nc-gaertnma at netcologne.de
Tue May 1 20:17:01 CEST 2012


On Tue, 01 May 2012 15:05:57 +0200
Sven Barth <pascaldragon at googlemail.com> wrote:

>[...]
> You can locally disable warnings by using the $warn directive (not 
> documented yet it seems, but available in 2.6.0).
> 
> It looks like this:
> 
> {$warn MSGID (on|off|error)}
> 
> * on: MSGID will be emitted as a warning
> * off: MSGID will not be emitted
> * error: MSGID will be emitted as an error (and handled as such by the 
> compiler!)
> 
> You can find out the MSGID by passing "-vq" to the compiler then it will 
> additionally print the ID for each message it writes. For the case of 
> "deprecated" there are two message IDs: One which is used if a custom 
> message is given and one for the other case. For the first the ID is 
> 5066 and for the latter 5043.
> 
> The following is a demonstration of the potential usage of $warn:
> 
> === example begin ===
> 
> program warntest;
> 
> {$mode objfpc}
> 
> type
>    TTest = class
>      procedure Test; deprecated 'Test';
>    end;
> 
> procedure TTest.Test;
> begin
> 
> end;
> 
> var
>    t: TTest;
> begin
> {$push} // <= used to restore the state afterwards; you could use {$warn 
> 5066 on} as well
> {$warn 5066 off}
>    t.Test; // here no warning will be emitted
> {$pop}
>    t.Test; // here a warning will be emitted
> end.
> 
> === example end ===
> 
> Alternatively you can also use
> 
> {$warn symbol_deprecated off}
> 
> which will switch of both custom and non-custom deprecated messages for 
> symbols (units have an extra name).
> 
> Here is a list of all those recognized identifiers (out of Delphi 
> compatibility):
> 
> CONSTRUCTING_ABSTRACT
> IMPLICIT_VARIANTS
> NO_RETVAL
> SYMBOL_DEPRECATED
> SYMBOL_EXPERIMENTAL
> SYMBOL_LIBRARY
> SYMBOL_PLATFORM
> SYMBOL_UNIMPLEMENTED
> UNIT_DEPRECATED
> UNIT_EXPERIMENTAL
> UNIT_LIBRARY
> UNIT_PLATFORM
> UNIT_UNIMPLEMENTED
> ZERO_NIL_COMPAT
> IMPLICIT_STRING_CAST
> IMPLICIT_VARIANTS
> NO_RETVAL
> SYMBOL_DEPRECATED
> SYMBOL_EXPERIMENTAL
> SYMBOL_LIBRARY
> SYMBOL_PLATFORM
> SYMBOL_UNIMPLEMENTED
> UNIT_DEPRECATED
> UNIT_EXPERIMENTAL
> UNIT_LIBRARY
> UNIT_PLATFORM
> UNIT_UNIMPLEMENTED
> ZERO_NIL_COMPAT
> IMPLICIT_STRING_CAST
> IMPLICIT_STRING_CAST_LOSS
> EXPLICIT_STRING_CAST
> EXPLICIT_STRING_CAST_LOSS
> CVT_NARROWING_STRING_LOST

Thanks. I added them to codetools.
Is there a similar list for notes and hints?

Mattias



More information about the fpc-devel mailing list