O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conditional compilation

haXe allows you to do conditional compilation. This means that some parts of the code can be compiled and others can be ignored depending on the flags you give to the compiler and depending on the platform you're targeting.

Conditional compilation instructions always begin with the #if instruction.

Conditional compilation depending on flags

You can define a flag on the command line by using the -D switch. So, to define the myway flag, you would use the following: -D myway.

Then, you use it in the following way:

#if myway //Code here compiled only if myway is defined #else //Code here compiled in the other case #end

There is also a not operator:

#if !myway //Code here compiled only myway is not defined #end

Conditional compilation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required