Delphi xe2's hidden hints and warnings options

Source: Internet
Author: User
There are a number of warnings available in Delphi xe2 that are not very well known ented. While you can control them in the Project Options dialog, and you can turn them on using {$ Warn} Directives or in command line compiler options, the documentation for the warning identifiers is currently pretty piecemeal, and there is no clear link between the project options, warning directive identifiers, and numeric identifiers.

The{$ Warn}Compiler Directive takes effect only in the unit it is in. it overrides Project Settings and command line compiler flags. to turn a warning on or off for a block of code (although you'll have to work hard to convince me that this is an acceptable solution 99% of the time ):

{$ Warn symbol_deprecated on} {$ warn symbol_deprecated off}

To restore the warning to its previous setting:

{$ Warn symbol_deprecated default}

And finally, you can convert a warning into an error:

{$ Warn symbol_deprecated error}

To change the setting in your project, go to project | options, Delphi compiler, hints and warnings, and expand the output warnings setting:

Delphi's Project Options dialog-hints and warnings

To change the setting in the command line compiler, use the-W flag, for example:

Dcc32-W + symbol_deprecated myproject. DPR
W-SYMBOL_DEPRECATED myproject. DPR

Or to turn the warning into an error:

Dcc32-w ^ symbol_deprecated myproject. DPR

Note, if you type this from the Windows command prompt, you will have to repeat the ^ symbol, as ^ is an escape symbol:

Dcc32-w ^ symbol_deprecated myproject. DPR

These are the hints and warning identifiers I am aware, along with what I understand are the default settings and numeric identifiers, and links to the relevant Help topics.

ID

Directive ID Default Description Notes
W1000 Symbol_deprecated Off Symbol '% s' is deprecated (Delphi)  
W1001 Symbol_library Off Symbol '% s' is specific to a library (Delphi)  
W1002 Symbol_platform Off Symbol '% s' is specific to a platform (Delphi)  
W1003 Symbol_experimental On Symbol '% s' is experimental (Delphi)  
W1004 Unit_library Off Unit '% s' is specific to a library (Delphi)  
W1005 Unit_platform Off Unit '% s' is specific to a platform (Delphi)  
W1006 Unit_deprecated Off Unit '% s' is deprecated (Delphi)  
W1007 Unit_experimental On Unit '% s' is experimental (Delphi)  
W1008 Hresult_compat On Integer and hresult interchanged  
W1009 Hiding_member On Redeclaration of '% s' hides a member in the base class (Delphi)  
W1010 Hidden_virtual On Method '% s' hides virtual method of base type' % s' (Delphi)  
W1011 Garbage On Text after final 'end. '-ignored by Compiler (Delphi)  
W1012 Bounds_error On Constant expression violates subrange Bounds  
W1013 Zero_nil_compat On Constant 0 converted to nil (Delphi)  
W1014 String_const_trunced On String constant truncated to fit string % LD (Delphi)  
W1015 For_loop_var_varpar On For-loop variable '% s' cannot be passed as VaR parameter (Delphi)  
W1016 Typed_const_varpar On Typed constant '% s' passed as VaR parameter (Delphi)  
W1017 Asg_to_typed_const On Assignment to typed constant '% s' (Delphi)  
W1018 Case_label_range On Case label outside of range of case expression (Delphi)  
X1019 For_variable On For loop control variable must be simple local variable (Delphi)  
X1020 Constructing_abstract On Constructing instance of '% s' ining abstract method' % S. % s' (Delphi)  
W1021 Comparison_false On Comparison always evaluates to false (Delphi)  
W1022 Comparison_true On Comparison always evaluates to true (Delphi)  
W1023 Comparing_signed_unsigned On Comparing signed and unsigned types-widened both operands (Delphi)  
W1024 Combining_signed_unsigned On Combining signed and unsigned types-widened both operands (Delphi)  
X1025 Unsupported_construct On Unsupported language feature: '% s' (Delphi)  
X1026 File_open On File not found '% s' (Delphi) Despite being listed as a warning, turning this off appears to have no effect.
F1027 File_open_unitsrc On Unit not found '% s' or binary equivalents (% s) (Delphi)  
X1028 Bad_global_symbol On Bad global symbol definition '% s' in object file' % s' (Delphi)  
W1029 Duplicate_ctor_dtor On Duplicate % s '% s' with identical parameters will be inacessible from C ++ (Delphi)  
X1030 Invalid_directive On Invalid compiler directive-'% s' (Delphi)  
W1031 Package_no_link On Package '% s' will not be written to disk because-J option is enabled (Delphi)  
W1032 Packaged_threadvar On Exported package threadvar '% S. % s' cannot be used outside of this package (Delphi)  
W1033 Implicit_import On Unit '% s' implicitly imported into package' % s' (Delphi)  
W1034 Hppemit_ignored On $ Hppemit '% s' ignored (Delphi)  
W1035 No_retval On Return Value of function '% s' might be undefined (Delphi)  
W1036 Use_before_def On Variable '% s' might not have been initialized (Delphi)  
W1037 For_loop_var_undef On For-loop variable '% s' may be undefined after loop (Delphi)  
E1038 Unit_name_mismatch On Unit identifier '% s' does not match file name (Delphi)  
W1039 No_pai_file_found On No configuration files found (Delphi)  
W1040 Implicit_variants On Implicit use of variants unit (Delphi)  
W1041 Unicode_to_locale On Error converting Unicode Char to locale charset. String truncated. Is your Lang environment variable set correctly (Delphi)  
W1042 Locale_to_unicode On Error converting locale string '% s' to Unicode. String truncated. Is your Lang environment variable set correctly (Delphi)  
W1043 Imagebase_multiple On Imagebase $ % x is not a multiple of 64 K. rounding down to $ % x (Delphi)  
W1044 Suspicious_typecast On Suspicious typecast of % s to % s (Delphi)  
W1045 Private_propaccessor On Property declaration references ancestor private '% S. % s' (Delphi)  
W1046 Unsafe_type Off Unsafe type '% S % s' (Delphi)  
W1047 Unsafe_code Off Unsafe code '% s' (Delphi)  
W1048 Unsafe_cast Off Unsafe typecast of '% s' to' % s' (Delphi)  
W1049 Option_truncated On Value '% s' for Option % s was truncated (Delphi)  
W1050 Widechar_reduced On Widechar sorted CED to byte char in set expressions (Delphi)  
W1051 Duplicates_ignored On Duplicate Symbol names in namespace. Using '% S. % s' found in % S. Ignoring duplicate in % s (Delphi)  
W1052 Unit_init_seq On Can't find system. runtime. compilerservices. runclassconstructor. Unit initialization order will not follow uses clause order Does not seem to be encoded ented in xe2
W1053 Local_pinvoke On Local pinvoke Code has not been made because external routine '% s' in package' % s' is defined using package local types in its Custom Attributes Does not seem to be encoded ented in xe2
X1054 Message_directive On % S (Delphi) User-Defined warning messages (see below). Turns Off message hints as well but not message errors.
W1055 Typeinfo_implicitly_added On Published caused rtti ($ m +) to be added to type '% s' (Delphi)  
X1056 Rlink_warning On Duplicate Resource Type % s, Id % s; file % s resource kept; file % s resource discarded (Delphi)  
W1057 Implicit_string_cast On Implicit string cast from '% s' to' % s' (Delphi)  
W1058 Implicit_string_cast_loss On Implicit string cast with potential data loss from '% s' to' % s' (Delphi)  
W1059 Explicit_string_cast Off Explicit string cast from '% s' to' % s' (Delphi)  
W1060 Explicit_string_cast_loss Off Explicit string cast with potential data loss from '% s' to' % s' (Delphi)  
W1061 Cvt_wchar_to_achar On W1061 narrowing given widechar constant ('% s') to ansichar lost information (Delphi)  
W1062 Cvt_narrowing_string_lost On Narrowing given wide String constant lost information (Delphi)  
W1063 Cvt_achar_to_wchar On Widening given ansichar constant ('% s') to widechar lost information (Delphi)  
W1064 Cvt_widening_string_lost On Widening given ansistring constant lost information (Delphi)  
W1066 Non_portable_typecast On Lost Extended Floating Point precision. Ced CED to double (Delphi)  
W1201 Xml_whitespace_not_allowed On XML comment on '% s' has badly formed XML-' whitespace is not allowed at this location. '(Delphi)  
W1202 Xml_unknown_entity On XML comment on '% s' has badly formed XML-'reference to undefined entity' % s (Delphi)  
W1203 Xml_invalid_name_start On XML comment on '% s' has badly formed XML-'a name was started with an invalid character.' (Delphi)  
W1204 Xml_invalid_name On XML comment on '% s' has badly formed XML-'a name contained an invalid character.' (Delphi)  
W1205 Xml_expected_character On XML comment on '% s' has badly formed XML-'the character' % C' was expected. '(Delphi)  
W1206 Xml_cref_no_resolve On XML comment on '% s' has CREF attribute' % s' that cocould not be resolved (Delphi)  
W1207 Xml_no_parm On XML comment on '% s' has a Param tag for' % s', but there is no parameter by that name (Delphi)  
W1208 Xml_no_matching_parm On Parameter '% s' has no matching Param tag in the XML comment for' % s' (but other parameters do) (Delphi)  

The$ MessageDirective allows generationH1054,W1054,E1054AndF1054Messages. User-Defined hint and warning messages can be turned off{$ Warn message_directive off}But logically enough, user-defined error and fatal messages can not be disabled. For example, add the following line to myunit. PAS:

{$ Message warn 'this is a user warning '}

Which will gives a compiler warning similar to the following:

[DCC Warning] myunit. PAS (25): w1054 this is a user warning

Finally, I'm not going to discuss$ WarningsDirective, doesn t to say that I don't think it's ever necessary or sensible to turn it off. if you must turn a warning off for a specific section of code, turn just that warning off as discussed above. using{$ Warnings off}Is just as unhelpful as an emptyExceptBlock.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.