Compiler directives for #if #else?

I can’t seem to find any docs that outline what compiler directives I can use. A couple links I found were dead.

I want to do something like:

#if !html5 and !flash
   trace(System.applicationStorageDirectory);
#else
   trace("localhost");
#end

but it seems that this causes a compilation issue.
What is the correct way to do this?

try:

#if !(html5 || flash)
    ...
#else
    ...
#end
2 Likes

That seems to work, thank you!

1 Like

You can also use #if sys, which is a standard Haxe define for targets that support the “sys” package (file system access, process support, etc)

1 Like

I got an error when trying to use sys with the HTML5 build which was expected really.

I wrapped all sys calls in #if !(html5 || flash) from then on, but #if sys looks like a little less visual noise :slight_smile:

It looks like you have this covered, but if you ever end up doing something more complicated, the documentation lists a bunch more options.