Delphi的$ WARN编译器指令的标识符
Delphi有一个$ WARN编译器指令,允许用户select性地启用或禁用特定的警告。 Delphi 2009帮助文件描述了语法:
{$WARN identifier ON|OFF}
但是它只列出了6个警告的标识符。
我想要所有的警告标识符的完整列表。 特别是,我想知道Delphi 2009中隐式string强制转换警告W1057和W1058的标识符。
我设法猜测隐式Ansi-> Unicode转换(W1057):
{$WARN IMPLICIT_STRING_CAST OFF}
谷歌search为我find另一个:
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
虽然这解决了我的迫切需求,但我仍然想知道警告标识符的完整列表。 像这样的东西应该被logging。
我查看了帮助,没有看到一个完整的列表…所以编译代码看起来编译器警告常量都列在:CodeGear \ RAD Studio \ 6.0 \ sources \ toolsapi \ DCCStrs.pas
search“Implicit_String_Cast_Loss”,你会看到常量sIMPLICIT_STRING_CAST_LOSS ='DCC_IMPLICIT_STRING_CAST_LOSS';
我会假设其余的DCC_xxxstring与相应的X_true / _false / _error定义是你在之后。
从Delphi 7开始,在线帮助并不是很好。
Darian的DCCStrs.pas列出了Delphi编译器使用的标识符。 我没有想过要search源代码,因为Delphi不包括其编译器的源代码。
我已经从该文件中提取了提示和警告的标识符:
-
{$WARN ASG_TO_TYPED_CONST OFF}
-
{$WARN BAD_GLOBAL_SYMBOL OFF}
-
{$WARN BOUNDS_ERROR OFF}
-
{$WARN CASE_LABEL_RANGE OFF}
-
{$WARN COMBINING_SIGNED_UNSIGNED OFF}
-
{$WARN COMPARING_SIGNED_UNSIGNED OFF}
-
{$WARN COMPARISON_FALSE OFF}
-
{$WARN COMPARISON_TRUE OFF}
-
{$WARN CONSTRUCTING_ABSTRACT OFF}
-
{$WARN CVT_ACHAR_TO_WCHAR OFF}
-
{$WARN CVT_NARROWING_STRING_LOST OFF}
-
{$WARN CVT_WCHAR_TO_ACHAR OFF}
-
{$WARN CVT_WIDENING_STRING_LOST OFF}
-
{$WARN DUPLICATE_CTOR_DTOR OFF}
-
{$WARN DUPLICATES_IGNORED OFF}
-
{$WARN EXPLICIT_STRING_CAST OFF}
-
{$WARN EXPLICIT_STRING_CAST_LOSS OFF}
-
{$WARN FILE_OPEN OFF}
-
{$WARN FILE_OPEN_UNITSRC OFF}
-
{$WARN FOR_LOOP_VAR_UNDEF OFF}
-
{$WARN FOR_LOOP_VAR_VARPAR OFF}
-
{$WARN FOR_VARIABLE OFF}
-
{$WARN GARBAGE OFF}
-
{$WARN HIDDEN_VIRTUAL OFF}
-
{$WARN HIDING_MEMBER OFF}
-
{$WARN HPPEMIT_IGNORED OFF}
-
{$WARN HRESULT_COMPAT OFF}
-
{$WARN IMAGEBASE_MULTIPLE OFF}
-
{$WARN IMPLICIT_IMPORT OFF}
-
{$WARN IMPLICIT_STRING_CAST OFF}
-
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
-
{$WARN IMPLICIT_VARIANTS OFF}
-
{$WARN INVALID_DIRECTIVE OFF}
-
{$WARN LOCAL_PINVOKE OFF}
-
{$WARN LOCALE_TO_UNICODE OFF}
-
{$WARN MESSAGE_DIRECTIVE OFF}
-
{$WARN NO_CFG_FILE_FOUND OFF}
-
{$WARN NO_RETVAL OFF}
-
{$WARN OPTION_TRUNCATED OFF}
-
{$WARN PACKAGE_NO_LINK OFF}
-
{$WARN PACKAGED_THREADVAR OFF}
-
{$WARN PRIVATE_PROPACCESSOR OFF}
-
{$WARN RLINK_WARNING OFF}
-
{$WARN STRING_CONST_TRUNCED OFF}
-
{$WARN SUSPICIOUS_TYPECAST OFF}
-
{$WARN SYMBOL_DEPRECATED OFF}
-
{$WARN SYMBOL_EXPERIMENTAL OFF}
-
{$WARN SYMBOL_LIBRARY OFF}
-
{$WARN SYMBOL_PLATFORM OFF}
-
{$WARN TYPED_CONST_VARPAR OFF}
-
{$WARN TYPEINFO_IMPLICITLY_ADDED OFF}
-
{$WARN UNICODE_TO_LOCALE OFF}
-
{$WARN UNIT_DEPRECATED OFF}
-
{$WARN UNIT_EXPERIMENTAL OFF}
-
{$WARN UNIT_INIT_SEQ OFF}
-
{$WARN UNIT_LIBRARY OFF}
-
{$WARN UNIT_NAME_MISMATCH OFF}
-
{$WARN UNIT_PLATFORM OFF}
-
{$WARN UNSAFE_CAST OFF}
-
{$WARN UNSAFE_CODE OFF}
-
{$WARN UNSAFE_TYPE OFF}
-
{$WARN UNSUPPORTED_CONSTRUCT OFF}
-
{$WARN USE_BEFORE_DEF OFF}
-
{$WARN WIDECHAR_REDUCED OFF}
-
{$WARN XML_CREF_NO_RESOLVE OFF}
-
{$WARN XML_EXPECTED_CHARACTER OFF}
-
{$WARN XML_INVALID_NAME OFF}
-
{$WARN XML_INVALID_NAME_START OFF}
-
{$WARN XML_NO_MATCHING_PARM OFF}
-
{$WARN XML_NO_PARM OFF}
-
{$WARN XML_UNKNOWN_ENTITY OFF}
-
{$WARN XML_WHITESPACE_NOT_ALLOWED OFF}
-
{$WARN ZERO_NIL_COMPAT OFF}
在Delphi 2009文档中没有提到的其他内容:
除了ON和OFF,$ WARN指令现在还有第三个选项ERROR。 所以你可以有:
{$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