Actually, neither of these work. The < 4 condition is not part of the conditional unless you enclose it in parens:
trace(#if (haxe_ver < 4) "Haxe is great!" #else "foo" #end);
The haxe define is meant to be used together with the SemVer comparison syntax that was added in Haxe 4:
trace(#if (haxe < version("4.0.0")) "Haxe is great!" #else "foo" #end);
However, that’s more for “granular” checks (and it won’t have the desired effect either - because the syntax is new, it won’t parse with Haxe 3.x). If you just want to check for Haxe 4, simply use the haxe4 define.
trace(#if !haxe4 "Haxe is great!" #else "foo" #end);
I’m sorry it’s also my fault, I’ve several error and in fact #if (haxe_ver >= 4) works but I was confused with another error and thought it was this one.
Anyway it’s good to know all this conditions