From 683595fee15a1d8ceeb1bbd577d96ed9c0f8aaaa Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 30 Mar 2009 11:55:13 +0200 Subject: [PATCH] Silence a bunch of warnings under MSVC /W4 Still some remain, but are really the silly ones. No functional change. Signed-off-by: Marco Costalba --- src/color.h | 2 +- src/endgame.cpp | 2 +- src/movepick.h | 2 ++ src/pawns.cpp | 4 ++-- src/piece.cpp | 4 ++-- src/piece.h | 2 +- src/position.cpp | 6 +++--- src/position.h | 6 +++++- src/search.cpp | 12 ++++++------ src/square.h | 8 ++++---- src/timeoday.cpp | 2 +- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/color.h b/src/color.h index 872c7b79..30d86d6b 100644 --- a/src/color.h +++ b/src/color.h @@ -38,7 +38,7 @@ enum Color { //// inline Color operator+ (Color c, int i) { return Color(int(c) + i); } -inline void operator++ (Color &c, int i) { c = Color(int(c) + 1); } +inline void operator++ (Color &c, int) { c = Color(int(c) + 1); } inline Color opposite_color(Color c) { return Color(int(c) ^ 1); diff --git a/src/endgame.cpp b/src/endgame.cpp index f6e4fd3f..f82beef6 100644 --- a/src/endgame.cpp +++ b/src/endgame.cpp @@ -383,7 +383,7 @@ Value EvaluationFunction::apply(const Position& pos) { } template<> -Value EvaluationFunction::apply(const Position &pos) { +Value EvaluationFunction::apply(const Position&) { return Value(0); } diff --git a/src/movepick.h b/src/movepick.h index c2619be8..a5403e09 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -47,6 +47,8 @@ struct SearchStack; class MovePicker { + MovePicker& operator=(const MovePicker&); // Silence a warning under MSVC + public: enum MovegenPhase { diff --git a/src/pawns.cpp b/src/pawns.cpp index b9d112f0..f06d9f12 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -121,8 +121,8 @@ namespace { }; // Pawn storm open file bonuses by file - const int KStormOpenFileBonus[8] = { 45, 45, 30, 0, 0, 0, 0, 0 }; - const int QStormOpenFileBonus[8] = { 0, 0, 0, 0, 0, 30, 45, 30 }; + const int16_t KStormOpenFileBonus[8] = { 45, 45, 30, 0, 0, 0, 0, 0 }; + const int16_t QStormOpenFileBonus[8] = { 0, 0, 0, 0, 0, 30, 45, 30 }; // Pawn storm lever bonuses by file const int StormLeverBonus[8] = { 20, 20, 10, 0, 0, 10, 20, 20 }; diff --git a/src/piece.cpp b/src/piece.cpp index 382ed645..40babba6 100644 --- a/src/piece.cpp +++ b/src/piece.cpp @@ -35,8 +35,8 @@ static const char PieceChars[] = " pnbrqk"; -int piece_type_to_char(PieceType pt, bool upcase) { - return upcase? toupper(PieceChars[pt]) : PieceChars[pt]; +char piece_type_to_char(PieceType pt, bool upcase) { + return char(upcase? toupper(PieceChars[pt]) : PieceChars[pt]); } PieceType piece_type_from_char(char c) { diff --git a/src/piece.h b/src/piece.h index cf23c028..5e1e58c6 100644 --- a/src/piece.h +++ b/src/piece.h @@ -104,7 +104,7 @@ inline bool piece_is_ok(Piece pc) { //// Prototypes //// -extern int piece_type_to_char(PieceType pt, bool upcase = false); +extern char piece_type_to_char(PieceType pt, bool upcase = false); extern PieceType piece_type_from_char(char c); diff --git a/src/position.cpp b/src/position.cpp index 591d48fb..1081e1da 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -755,7 +755,7 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) { st->capture = type_of_piece_on(to); if (st->capture) - do_capture_move(m, st->capture, them, to); + do_capture_move(st->capture, them, to); // Move the piece clear_bit(&(byColorBB[us]), from); @@ -848,7 +848,7 @@ void Position::do_move(Move m, StateInfo& newSt, Bitboard dcCandidates) { /// Position::do_capture_move() is a private method used to update captured /// piece info. It is called from the main Position::do_move function. -void Position::do_capture_move(Move m, PieceType capture, Color them, Square to) { +void Position::do_capture_move(PieceType capture, Color them, Square to) { assert(capture != KING); @@ -1010,7 +1010,7 @@ void Position::do_promotion_move(Move m) { st->capture = type_of_piece_on(to); if (st->capture) - do_capture_move(m, st->capture, them, to); + do_capture_move(st->capture, them, to); // Remove pawn clear_bit(&(byColorBB[us]), from); diff --git a/src/position.h b/src/position.h index e5b5f5aa..d2b37478 100644 --- a/src/position.h +++ b/src/position.h @@ -27,6 +27,10 @@ // Forcing value to bool 'true' or 'false' (performance warning) #pragma warning(disable: 4800) +// Conditional expression is constant +#pragma warning(disable: 4127) + + #endif //// @@ -305,7 +309,7 @@ private: void allow_ooo(Color c); // Helper functions for doing and undoing moves - void do_capture_move(Move m, PieceType capture, Color them, Square to); + void do_capture_move(PieceType capture, Color them, Square to); void do_castle_move(Move m); void do_promotion_move(Move m); void do_ep_move(Move m); diff --git a/src/search.cpp b/src/search.cpp index 434587a8..806a9be1 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -258,7 +258,7 @@ namespace { Depth depth, int ply, int threadID); void sp_search(SplitPoint *sp, int threadID); void sp_search_pv(SplitPoint *sp, int threadID); - void init_node(const Position &pos, SearchStack ss[], int ply, int threadID); + void init_node(SearchStack ss[], int ply, int threadID); void update_pv(SearchStack ss[], int ply); void sp_update_pv(SearchStack *pss, SearchStack ss[], int ply); bool connected_moves(const Position &pos, Move m1, Move m2); @@ -959,7 +959,7 @@ namespace { // Initialize, and make an early exit in case of an aborted search, // an instant draw, maximum ply reached, etc. - init_node(pos, ss, ply, threadID); + init_node(ss, ply, threadID); // After init_node() that calls poll() if (AbortSearch || thread_should_stop(threadID)) @@ -1155,7 +1155,7 @@ namespace { // Initialize, and make an early exit in case of an aborted search, // an instant draw, maximum ply reached, etc. - init_node(pos, ss, ply, threadID); + init_node(ss, ply, threadID); // After init_node() that calls poll() if (AbortSearch || thread_should_stop(threadID)) @@ -1424,7 +1424,7 @@ namespace { // Initialize, and make an early exit in case of an aborted search, // an instant draw, maximum ply reached, etc. - init_node(pos, ss, ply, threadID); + init_node(ss, ply, threadID); // After init_node() that calls poll() if (AbortSearch || thread_should_stop(threadID)) @@ -1451,6 +1451,7 @@ namespace { EvalInfo ei; Value staticValue; bool isCheck = pos.is_check(); + ei.futilityMargin = Value(0); // Manually initialize futilityMargin if (isCheck) staticValue = -VALUE_INFINITE; @@ -1462,7 +1463,6 @@ namespace { assert(ei.futilityMargin == Value(0)); staticValue = tte->value(); - ei.futilityMargin = Value(0); // manually initialize futilityMargin } else staticValue = evaluate(pos, ei, threadID); @@ -2025,7 +2025,7 @@ namespace { // NodesBetweenPolls nodes, init_node() also calls poll(), which polls // for user input and checks whether it is time to stop the search. - void init_node(const Position &pos, SearchStack ss[], int ply, int threadID) { + void init_node(SearchStack ss[], int ply, int threadID) { assert(ply >= 0 && ply < PLY_MAX); assert(threadID >= 0 && threadID < ActiveThreads); diff --git a/src/square.h b/src/square.h index e8c69327..4f024c96 100644 --- a/src/square.h +++ b/src/square.h @@ -163,16 +163,16 @@ inline File file_from_char(char c) { return File(c - 'a') + FILE_A; } -inline int file_to_char(File f) { - return int(f - FILE_A) + 'a'; +inline char file_to_char(File f) { + return char(f - FILE_A) + 'a'; } inline Rank rank_from_char(char c) { return Rank(c - '1') + RANK_1; } -inline int rank_to_char(Rank r) { - return int(r - RANK_1) + '1'; +inline char rank_to_char(Rank r) { + return char(r - RANK_1) + '1'; } inline Square square_from_string(const std::string& str) { diff --git a/src/timeoday.cpp b/src/timeoday.cpp index ed1a2a90..6909c2dc 100644 --- a/src/timeoday.cpp +++ b/src/timeoday.cpp @@ -9,7 +9,7 @@ #include #include "dos.h" -int gettimeofday(struct timeval* tp, struct timezone* tzp) +int gettimeofday(struct timeval* tp, struct timezone*) { SYSTEMTIME systime; -- 2.39.2