警告メッセージ(Delphi)
Delphi コンパイラ指令のリスト:インデックス への移動
種類 |
スイッチ |
構文 |
{$WARN <識別子> ON | OFF | ERROR | DEFAULT} |
Default: |
すべての警告が有効です。 |
スコープ |
ローカル |
説明
$WARN 指令を使用すると、個々の警告メッセージをきめ細かく制御できます。
構文 | 効果 |
---|---|
{$WARN <識別子> ON} |
識別子で指定された警告をコンパイラが表示できるようになります。 |
{$WARN <識別子> OFF} |
指定された警告は表示されません。 |
{$WARN identifier ERROR} |
指定された警告はエラーとして扱われます。 |
{$WARN <識別子> DEFAULT} |
[<プロジェクト名> のプロジェクト オプション]ダイアログ ボックスで指定されているデフォルト設定を使用します。 |
その警告は、ヒント指令(platform、deprecated、および library)が指定されているシンボルやユニットに関係するものです。
$WARN 指令の <識別子> は、次の値の中から指定することができます。
- BOUNDS_ERROR: Delphi 4 より前の Delphi のバージョンに大きい符号なしの型がないために現在では無効になっている変換が行われたときに出力される警告を、オンまたはオフにします。
(「X1012 範囲外の定数式です(Delphi)」を参照)。
- GARBAGE: プログラム、ユニット、ライブラリ、パッケージの終わりを表す 'end.' の後に、ホワイトスペース以外のテキストが存在するときに出力される警告を、オンまたはオフにします。
(「W1011 コンパイラは 'end.' 以降の文字を無視します - (Delphi)」を参照)。
- HIDDEN_VIRTUAL: 上位クラスのメソッドと同じ名前のメソッドを下位クラスで宣言していて、上位クラスのメソッドが仮想メソッドなのに、下位クラスのメソッドがオーバーライドではない場合に出力される警告を、オンまたはオフにします
(「W1010 メソッド '%s' で基底型 '%s' の仮想メソッドが隠蔽されます(Delphi)」を参照)。
- HIDING_MEMBER: 上位クラスのプロパティと同じ名前を持つ新しいプロパティを下位クラスで宣言したときに出力される警告を、オンまたはオフにします
(「W1009 '%s' の再宣言のため基本クラスのメンバーが隠蔽されました (Delphi)」を参照)。
- HRESULT_COMPAT: 'HRESULT' を使用するべき箇所で 'Integer' 型を使用した場合の警告を、オンまたはオフにします
(「X1008 Integer と HRESULT が入れ替わっています (Delphi)」を参照)。
- STRING_CONST_TRUNCED: コンパイラが文字列リテラルや定数値を短い文字列に代入しようとして、その場所に文字列全体が入りきらない場合の警告を、すべてオンまたはオフにします
(「W1014 string[%ld] に収まるように文字列定数が丸められました (Delphi)」を参照)。
- SYMBOL_DEPRECATED: 現在のユニット内のシンボルに付けられた deprecated 指令についての警告を、すべてオンまたはオフにします
(「W1000 シンボル '%s' を使用することは推奨されていません (Delphi)」を参照)。 - SYMBOL_EXPERIMENTAL:現在のユニット内のシンボルに付けられた experimental 指令についての警告を、すべてオンまたはオフにします
(「W1003 シンボル '%s' はテスト用です (Delphi)」を参照)。 - SYMBOL_PLATFORM: 現在のユニット内のシンボルに付けられた platform 指令についての警告を、すべてオンまたはオフにします
(「W1002 シンボル '%s' はプラットフォームに依存すると宣言されています (Delphi)」を参照)。
- SYMBOL_LIBRARY: 現在のユニット内のシンボルに付けられた library 指令についての警告を、すべてオンまたはオフにします
(「W1001 シンボル '%s' はライブラリに依存すると宣言されています (Delphi)」を参照)。
- UNIT_DEPRECATED: ユニット宣言に付けられた deprecated 指令についての警告を、すべてオンまたはオフにします
(「W1006 ユニット '%s' を使用することは推奨されていません (Delphi)」を参照)。
- UNIT_EXPERIMENTAL: ユニット宣言に付けられた experimental 指令についての警告を、すべてオンまたはオフにします
(「W1007 ユニット '%s' はテスト用です (Delphi)」を参照)。
- UNIT_LIBRARY: library 指令が指定されたユニットの library 指令についての警告を、すべてオンまたはオフにします
(「W1004 ユニット '%s' はライブラリに依存すると宣言されています (Delphi)」を参照)。
- UNIT_PLATFORM: platform 指令が指定されたユニットの platform 指令についての警告を、すべてオンまたはオフにします
(「W1005 ユニット '%s' はプラットフォームに依存すると宣言されています (Delphi)」を参照)。
- ZERO_NIL_COMPAT: コンパイラが 0 を nil 値のポインタに変換した場合の警告を、すべてオンまたはオフにします
(「W1013 定数 0 が NIL に変換されました (Delphi)」を参照)。
$WARN を使ってオン/オフできる警告は上記のものだけです。
インラインの $WARN 指令による警告の設定は、その指令が含まれるコンパイル ユニットに適用され、その後、元の状態に戻ります。 $WARN 指令の警告の設定が有効になるのは、ファイル中のその場所以降です。
$WARNINGS 指令を使ってコンパイラ警告の出力を制御することもできます。
例
次の $WARN 指令の場合は、現在のモジュールで experimental 指定のシンボルが参照されるとすべて警告が表示されます。
{$WARNINGS ON}
{$WARN SYMBOL_EXPERIMENTAL ON}
procedure Foo; experimental;
begin
end;
begin
Foo // Warning: W1003 Symbol 'Foo' is experimental
end.
上記の $WARN 指令が次のように変わると、
{$WARN SYMBOL_EXPERIMENTAL ERROR}
コンパイラ メッセージは次のように変わります。
Error: E1003 Symbol 'Foo' is experimental
そして、このモジュールはコンパイルされなくなります。
以下に例をもう 1 つ示します。
{$WARN WIDECHAR_REDUCED OFF}
if c in ['a', 'b'] then
// ...
{$WARN WIDECHAR_REDUCED DEFAULT}
Possible warnings:
• ID_DEPRECATED, //"x1000 Symbol '%s' is deprecated%s"
• ID_LIBRARY, //"x1001 Symbol '%s' is specific to a library"
• ID_PLATFORM, //"x1002 Symbol '%s' is specific to a platform"
• ID_EXPERIMENTAL, //"x1003 Symbol '%s' is experimental"
• UNIT_LIBRARY, //"x1004 Unit '%s' is specific to a library"
• UNIT_PLATFORM, //"x1005 Unit '%s' is specific to a platform"
• UNIT_DEPRECATED, //"x1006 Unit '%s' is deprecated"
• UNIT_EXPERIMENTAL, //"x1007 Unit '%s' is experimental"
• HRESULT_COMPAT, //"x1008 Integer and HRESULT interchanged"
• HIDING_MEMBER, //"x1009 Redeclaration of '%s' hides a member in the base class"
• HIDDEN_VIRTUAL, //"x1010 Method '%s' hides virtual method of base type '%s'"
• GARBAGE, //"x1011 Text after final 'END.' - ignored by compiler"
• BOUNDS_ERROR, //"x1012 Constant expression violates subrange bounds"
• ZERO_NIL_COMPAT, //"x1013 Constant 0 converted to NIL"
• STRING_CONST_TRUNCED, //"x1014 String constant truncated to fit STRING[%ld]"
• FOR_LOOP_VAR_VARPAR, //"x1015 FOR-Loop variable '%s' cannot be passed as var parameter"
• TYPED_CONST_VARPAR, //"x1016 Typed constant '%s' passed as var parameter"
• ASG_TO_TYPED_CONST, //"x1017 Assignment to typed constant '%s'"
• CASE_LABEL_RANGE, //"x1018 Case label outside of range of case expression"
• FOR_VARIABLE, //"x1019 For loop control variable must be simple local variable"
• CONSTRUCTING_ABSTRACT, //"x1020 Constructing instance of '%s' containing abstract method '%s.%s'"
• COMPARISON_FALSE, //"x1021 Comparison always evaluates to False"
• COMPARISON_TRUE, //"x1022 Comparison always evaluates to True"
• COMPARING_SIGNED_UNSIGNED, //"x1023 Comparing signed and unsigned types - widened both operands"
• COMBINING_SIGNED_UNSIGNED, //"x1024 Combining signed and unsigned types - widened both operands"
• UNSUPPORTED_CONSTRUCT, //"x1025 Unsupported language feature: '%s'"
• FILE_OPEN, //"x1026 File not found: '%s'"
• FILE_OPEN_UNITSRC, //"F1027 Unit not found: '%s' or binary equivalents (%s)"
• BAD_GLOBAL_SYMBOL, //"x1028 Bad global symbol definition: '%s' in object file '%s'"
• DUPLICATE_CTOR_DTOR, //"x1029 Duplicate %s '%s' with identical parameters will be inacessible from C++"
• INVALID_DIRECTIVE, //"x1030 Invalid compiler directive: '%s'"
• PACKAGE_NO_LINK, //"x1031 Package '%s' will not be written to disk because -J option is enabled"
• PACKAGED_THREADVAR, //"x1032 Exported package threadvar '%s.%s' cannot be used outside of this package"
• IMPLICIT_IMPORT, //"x1033 Unit '%s' implicitly imported into package '%s'"
• HPPEMIT_IGNORED, //"x1034 $HPPEMIT '%s' ignored"
• NO_RETVAL, //"x1035 Return value of function '%s' might be undefined"
• USE_BEFORE_DEF, //"x1036 Variable '%s' might not have been initialized"
• FOR_LOOP_VAR_UNDEF, //"x1037 FOR-Loop variable '%s' may be undefined after loop"
• UNIT_NAME_MISMATCH, //"E1038 Unit identifier '%s' does not match file name"
• NO_CFG_FILE_FOUND, //"x1039 No configuration files found"
• IMPLICIT_VARIANTS, //"x1040 Implicit use of Variants unit"
• UNICODE_TO_LOCALE, //"x1041 Error converting Unicode char to locale charset. String truncated. Is your LANG environment variable set correctly?"
• LOCALE_TO_UNICODE, //"x1042 Error converting locale string '%s' to Unicode. String truncated. Is your LANG environment variable set correctly?"
• IMAGEBASE_MULTIPLE, //"x1043 Imagebase $%X is not a multiple of 64k. Rounding down to $%X"
• SUSPICIOUS_TYPECAST, //"x1044 Suspicious typecast of %s to %s"
• PRIVATE_PROPACCESSOR, //"x1045 Property declaration references ancestor private '%s.%s'"
• UNSAFE_TYPE, //"x1046 Unsafe type '%s%s%s'"
• UNSAFE_CODE, //"x1047 Unsafe code '%s'"
• UNSAFE_CAST, //"x1048 Unsafe typecast of '%s' to '%s'"
• OPTION_TRUNCATED, //"x1049 value '%s' for option %s was truncated"
• WIDECHAR_REDUCED, //"x1050 WideChar reduced to byte char in set expressions. Consider using 'CharInSet' function in 'SysUtils' unit."
• DUPLICATES_IGNORED, //"x1051 Duplicate symbol names in namespace. Using '%s.%s' found in %s. Ignoring duplicate in %s"
• UNIT_INIT_SEQ, //"x1052 Can't find System.Runtime.CompilerServices.RunClassConstructor. Unit initialization order will not follow uses clause order"
• LOCAL_PINVOKE, //"x1053 Local PInvoke code has not been made because external routine '%s' in package '%s' is defined using package local types in its custom attributes" // (.Net only)
• MESSAGE_DIRECTIVE, //"x1054 %s"
• TYPEINFO_IMPLICITLY_ADDED, //"x1055 PUBLISHED caused RTTI ($M+) to be added to type '%s'"
• RLINK_WARNING, //"x1056 %s%s%s"
• IMPLICIT_STRING_CAST, //"x1057 Implicit string cast from '%s' to '%s'"
• IMPLICIT_STRING_CAST_LOSS, //"x1058 Implicit string cast with potential data loss from '%s' to '%s'"
• EXPLICIT_STRING_CAST, //"x1059 Explicit string cast from '%s' to '%s'"
• EXPLICIT_STRING_CAST_LOSS, //"x1060 Explicit string cast with potential data loss from '%s' to '%s'"
• CVT_WCHAR_TO_ACHAR, //"x1061 Narrowing given WideChar constant (#$%04X) to AnsiChar lost information"
• CVT_NARROWING_STRING_LOST, //"x1062 Narrowing given wide string constant lost information"
• CVT_ACHAR_TO_WCHAR, //"x1063 Widening given AnsiChar constant (#$%02X) to WideChar lost information"
• CVT_WIDENING_STRING_LOST, //"x1064 Widening given AnsiString constant lost information"
• NON_PORTABLE_TYPECAST, //"x1065 Typecast of %s to %s is non-portable; code may run differently on 32bit and 64bit platforms"
• LOST_EXT80_PRECISION, //"x1066 Lost Extended floating point precision. Reduced to Double"
• LNKDFM_NOTFOUND, //"x1067 Unable to load DLL %s"
• IMMUTABLE_STRINGS, //"x1068 Modifying strings in place may not be supported in the future"
• MOBILE_DELPHI, //"x1069 %s"
• UNSAFE_VOID_POINTER, //"x1070 Use of untype pointer can disrupt instance reference counts"
• XML_WHITESPACE_NOT_ALLOWED, //"x1201 XML comment on '%s' has badly formed XML -- 'Whitespace is not allowed at this location.'"
• XML_UNKNOWN_ENTITY, //"x1202 XML comment on '%s' has badly formed XML -- 'Reference to undefined entity '%s'.'"
• XML_INVALID_NAME_START, //"x1203 XML comment on '%s' has badly formed XML -- 'A name was started with an invalid character.'"
• XML_INVALID_NAME, //"x1204 XML comment on '%s' has badly formed XML -- 'A name contained an invalid character.'"
• XML_EXPECTED_CHARACTER, //"x1205 XML comment on '%s' has badly formed XML -- 'The character '%c' was expected.'"
• XML_CREF_NO_RESOLVE, //"x1206 XML comment on '%s' has cref attribute '%s' that could not be resolved"
• XML_NO_PARM, //"x1207 XML comment on '%s' has a param tag for '%s', but there is no parameter by that name"
• XML_NO_MATCHING_PARM, //"x1208 Parameter '%s' has no matching param tag in the XML comment for '%s' (but other parameters do)"
関連項目
- WARNINGS(Delphi) ($WARNINGS)
- 宣言と文(Delphi)
- 指令(基本的な構文要素内)