{$WARN SYMBOL_PLATFORM OFF} 不关闭警告

{$WARN SYMBOL_PLATFORM OFF} does not turn off warnings

我有这段代码:

INTERFACE

{$WARN SYMBOL_PLATFORM OFF}
USES
   Winapi.Windows, etc, {$IFDEF MSWINDOWS}Vcl.FileCtrl, {$ENDIF} System.IniFiles;
{$WARN SYMBOL_PLATFORM ON}

编译器显示:

[dcc32 Warning] W1005 Unit 'Vcl.FileCtrl' is specific to a platform

即使存在 {$WARN SYMBOL_PLATFORM OFF}。
为什么?

您使用了错误的指令。 SYMBOL_PLATFORM 控制 符号 标记为平台特定的警告。您的警告与标记为平台特定的 unit 相关。

使用 UNIT_PLATFORM 控制这些警告。

The whole unit is tagged (using the platform hint directive) as one that contains material that might not be available on all platforms. If you are writing multi-device applications, the unit might cause a problem. For example, a unit that uses objects defined in OleAuto might be tagged using the PLATFORM directive.

The $WARN UNIT_PLATFORM ON/OFF compiler directive turns on or off all warnings about the platform directive in units where the platform directive is specified.


有一种非常简单的方法可以让您自己解决这个问题。看看我上面链接的两个文档主题。他们的头衔是:

  • W1002 符号“%s”特定于平台 (Delphi)
  • W1005 单元“%s”特定于平台 (Delphi)

您收到的编译器警告将警告命名为 W1005。这就是您确定使用哪个指令来控制它所需知道的全部内容。如果您找不到它们,只需搜索警告名称,在本例中为 W1005。或者参考documentation that lists them all.