8.10 Warnings

since Haxe 4.3.0

The compiler emits warnings in various circumstances, which can be turned off and on in two ways:

  1. Globally with the command line argument -w options
  2. For specific types and fields with the metadata @:haxe.warning("options")

For both cases, the options syntax is the same:

  • Use -Identifier to disable warnings.
  • Use +Identifier to enable warnings.

Here is a simple example using the @:deprecated metadata:

@:deprecated function test() {}

function main() {

Compiling this in Haxe 4.3.0 emits a warning (WDeprecated) Usage of this field is deprecated. All warning messages are prefixed with their identifier, in this case WDeprecated, which can then be used to disable the warning accordingly:

  1. -w -WDeprecated disables all deprecation warnings for the current compilation.
  2. @:haxe.warning("-WDeprecated") disables deprecation warnings for the annotated type or field.

We can confirm this by compiling the simple example with the additional metadata annotation:

@:deprecated function test() {}

function main() {

Compiling this no longer causes a warning.

Enabling warnings is analoguous, using + instead of -, e.g. -w +WCustomWarning. Note that as of Haxe 4.3.0, there are no compiler warnings which are disabled by default, so the option is currently not useful.

Multiple warnings can be disabled and enabled within the same options string, so something like -w -WDeprecated-WUnusedPattern would disable both WDeprecated and WUnusedPattern warnings.

Warnings are organized as a tree, where disabling (or enabling) a parent warning affects all children. The root warning is WAll, which can be used to disable all warnings.

Trivia: -D no-deprecation-warnings

In Haxe versions before 4.3.0, deprecation warnings could only be disabled globally by using the -D no-deprecation-warnings compiler option. This define now implies -w -WDeprecated.