1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-02 17:49:35 +00:00

Fix a compile error in opposite_colors()

Error is due to ambiguous overloading of operator^
because we have both the built-in operator^(int, int)
and the user defined operator^(Bitboard, Square).

This error does not trigger when using Makefile becuase,
due to luck, the user defined operator^(Bitboard, Square)
happens to be always defined _after_ opposite_colors() so
that compiler does not claim. But in case of Microsoft MSVC
we don't have a Makefile and the order of files compilation
is chosen by the compiler (in an unpredictable way). So it
could still happen that error is not detected (as in my case),
but in another case the order of compilation of the files could
be so that at some point both operator^ were defined before
opposite_colors() and this triggers the error.

The fix is much simpler than the explanation :-)

Reported by Quocvuong82.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2012-06-02 08:51:58 +01:00
parent 0412f4a1ee
commit 764d3f44b6

View file

@ -392,7 +392,7 @@ inline Rank relative_rank(Color c, Square s) {
}
inline bool opposite_colors(Square s1, Square s2) {
int s = s1 ^ s2;
int s = int(s1) ^ int(s2);
return ((s >> 3) ^ s) & 1;
}