Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifiers for Delphi's $WARN compiler directive

Delphi has a $WARN compiler directive that allows one to selectively enable or disable specific warnings. The Delphi 2009 help file describes the syntax:

{$WARN identifier ON|OFF}

But it only lists the identifiers for 6 warnings.

I'd like to have a complete list of all the warning identifiers. In particular, I want to know the identifiers for the implicit string cast warnings W1057 and W1058 in Delphi 2009.

I managed to guess the one for implicit Ansi->Unicode casts (W1057):

{$WARN IMPLICIT_STRING_CAST OFF}

Googling for that found me the other one:

{$WARN IMPLICIT_STRING_CAST_LOSS OFF}

Though that solves my immediate need, I'd still like to know the complete list of warning identifiers. Stuff like this should be documented.

like image 766
Jan Goyvaerts Avatar asked Dec 18 '08 02:12

Jan Goyvaerts


3 Answers

I looked through the help and didn't see a full list...so poking around the code it appears the compiler warning constants are all listed in: CodeGear\RAD Studio\6.0\sources\toolsapi\DCCStrs.pas

Search for "Implicit_String_Cast_Loss" and you'll see the constant sIMPLICIT_STRING_CAST_LOSS = 'DCC_IMPLICIT_STRING_CAST_LOSS';

I would assume the rest of the DCC_xxx strings with corresponding X_true/_false/_error defines are what you are after.

Online help hasn't been very good since Delphi 7.

like image 43
Darian Miller Avatar answered Oct 23 '22 05:10

Darian Miller


Something else not mentioned in the Delphi 2009 documentation:

The $WARN directive now has a 3rd option ERROR in addition to ON and OFF. So you can have:

{$WARN IMPLICIT_STRING_CAST OFF} to disable the warning
{$WARN IMPLICIT_STRING_CAST ON} to enable warning
{$WARN IMPLICIT_STRING_CAST ERROR} to turn the warning into an error
like image 166
Jan Goyvaerts Avatar answered Oct 23 '22 05:10

Jan Goyvaerts


Stuff like this should be documented

As of today, the full list of identifiers and their compiler warning numbers are listed in the documentation at:

http://docwiki.embarcadero.com/RADStudio/en/Warning_messages_(Delphi)

Excerpt:

The identifier in the $WARN directive can have any of the following values:

|      Warning      | Identifier |
|:-----------------:|:----------:|
| SYMBOL_DEPRECATED | W1000      |
| SYMBOL_LIBRARY    | W1001      |
| (...)             | (...)      |
like image 6
Günther the Beautiful Avatar answered Oct 23 '22 05:10

Günther the Beautiful