Hi Alexandre,
> I am porting some PRG code to Harbour and in my first steps, I stumbled
> with xHarbour odd behaviors. For some functions, xHarbour and Harbour
> behavior is different and I need to, based in what compiler was used,
> produce diferent code.
>
> In Harbour, this worked fine using __HARBOUR__ define, but for xHarbour,
> using the __XHARBOUR__ define resulted in odd and unexpected results.
>
> How to tell them apart using a reliable (xHarbour-proof) method?
Not really unexpected :-)
In the beginning, __HARBOUR__ was #define'd to distinguish between
Harbour and Clipper. Then, in the xHarbour fork, __XHARBOUR__ was
#define'd to distiguish it from Harbour. But there was still need to
distinguish (x)Harbour from Clipper, so the original __HARBOUR__ was
kept alongside __XHARBOUR__
If you never need to worry about Clipper (or any other toolchain),
Gale's method of using a simple #else will do the trick to distinguish
between Harbour and xHarbour. If there is also a Clipper option, you
would have to do something like this:
#if defined( __XHARBOUR__ )
// xHarbour code here
#elif defined( __HARBOUR__ )
// Harbour code here
#else
// Clipper code here
#endif
Regards,
Klas