6.1.1 Target defines

Depending on the current target, at least one of the following flags will be defined. Note that they are the same as the argument provided to the compiler to specify the output.

  • as3 Defined when generating ActionScript 3 code.
  • cpp Defined when generating C++ code or a cppia script.
  • cppia Defined when generating a cppia script.
  • cs Defined when generating C# code.
  • eval Defined when running the code with --interp, or when running in a macro context.
  • hl Defined when generating HashLink code.
  • java Defined when generating Java code.
  • js Defined when generating JavaScript code.
  • lua Defined when generating Lua code.
  • neko Defined when generating a Neko binary.
  • php Defined when generating PHP code.
  • python Defined when generating Python code.
  • swf Defined when generating a SWF file.

Additionally, parts of code may be used in a macro context or during display completion. These flags can be used to check if this is the case:

  • display Defined when providing code completion.
  • macro Defined in a macro context.
Supported features
  • sys Defined if the target supports the sys API.
since Haxe 4.0.0

To provide more fine-grained knowledge about the features supported on the current target without having to manually check which target supports what, Haxe 4 provides the target.* defines:

  • target.static (or static) Defined if the target is static.
  • target.sys (or sys as noted above) Defined if the target supports the sys API.
  • target.utf16 (or utf16) Defined if the target uses UTF-16 for its internal string representation.
  • target.threaded Defined if the target supports the unified threading API.
  • target.name Defined to be the name of the target, e.g. js.