Getting the target compilation language in haxe

I know, I can do something like

public static function getTarget():String { #if flash return "Flash"; #elseif java return "Java"; //... some more elseif clauses ... #end } 

to determine the target language in haxe (see http://old.haxe.org/doc/snip/gettarget ). However, whenever a new target programming language is added (normally, this is not so often) the community - I will need to add another elseif sentence in order to "support / discover" this language ...

So, I was wondering if there is some kind of predefined macro / function that returns the target language as a string:

 trace("This is a " + getTargetLanguage() + " program!"); 
+5
source share
1 answer

I do not think such a thing exists.

To make sure getTarget() not getTarget() silently when adding a new target (and you are compiling it), you can force it to cause a compiler error in this case:

 public static function getTarget():String { #if flash return "Flash"; #elseif java return "Java"; //... some more elseif clauses ... #else #error "Missing target name" #end } 
+7
source

Source: https://habr.com/ru/post/1275830/


All Articles