silence some warnings on msvc
This commit is contained in:
parent
f97168241f
commit
2fff222235
10
Jamfile
10
Jamfile
|
@ -266,7 +266,15 @@ rule warnings ( properties * )
|
|||
{
|
||||
# disable warning C4503: decorated name length exceeded, name was truncated
|
||||
result += <cflags>/wd4503 ;
|
||||
result += <cflags>/W4 ;
|
||||
result += <warnings>all ;
|
||||
|
||||
# enable these warnings again, once the other ones are dealt with
|
||||
|
||||
# disable warning C4389: signed/unsigned mismatch
|
||||
result += <cflags>/wd4389 ;
|
||||
result += <cflags>/wd4245 ;
|
||||
# disable warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data
|
||||
result += <cflags>/wd4244 ;
|
||||
}
|
||||
|
||||
return $(result) ;
|
||||
|
|
|
@ -264,6 +264,9 @@ namespace libtorrent {
|
|||
#endif
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
alert& operator=(alert const&);
|
||||
|
||||
time_point m_timestamp;
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,18 @@ std::string demangle(char const* name);
|
|||
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0);
|
||||
#endif
|
||||
|
||||
// this is to disable the warning of conditional expressions
|
||||
// being constant in msvc
|
||||
#ifdef _MSC_VER
|
||||
#define TORRENT_WHILE_0 \
|
||||
__pragma( warning(push) ) \
|
||||
__pragma( warning(disable:4127) ) \
|
||||
while (0) \
|
||||
__pragma( warning(pop) )
|
||||
#else
|
||||
#define TORRENT_WHILE_0 while (0)
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
||||
#ifdef TORRENT_PRODUCTION_ASSERTS
|
||||
|
@ -70,15 +82,15 @@ TORRENT_EXPORT void assert_fail(const char* expr, int line
|
|||
, char const* file, char const* function, char const* val, int kind = 0);
|
||||
|
||||
#define TORRENT_ASSERT_PRECOND(x) \
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 1); } while (false)
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 1); } TORRENT_WHILE_0
|
||||
|
||||
#define TORRENT_ASSERT(x) \
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 0); } while (false)
|
||||
do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, 0, 0); } TORRENT_WHILE_0
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#define TORRENT_ASSERT_VAL(x, y) \
|
||||
do { if (x) {} else { std::stringstream __s__; __s__ << #y ": " << y; \
|
||||
assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, __s__.str().c_str(), 0); } } while (false)
|
||||
assert_fail(#x, __LINE__, __FILE__, TORRENT_FUNCTION, __s__.str().c_str(), 0); } } TORRENT_WHILE_0
|
||||
#else
|
||||
#define TORRENT_ASSERT_VAL(x, y) TORRENT_ASSERT(x)
|
||||
#endif
|
||||
|
@ -92,9 +104,9 @@ TORRENT_EXPORT void assert_fail(const char* expr, int line
|
|||
|
||||
#else // TORRENT_USE_ASSERTS
|
||||
|
||||
#define TORRENT_ASSERT_PRECOND(a) do {} while(false)
|
||||
#define TORRENT_ASSERT(a) do {} while(false)
|
||||
#define TORRENT_ASSERT_VAL(a, b) do {} while(false)
|
||||
#define TORRENT_ASSERT_PRECOND(a) do {} TORRENT_WHILE_0
|
||||
#define TORRENT_ASSERT(a) do {} TORRENT_WHILE_0
|
||||
#define TORRENT_ASSERT_VAL(a, b) do {} TORRENT_WHILE_0
|
||||
|
||||
#endif // TORRENT_USE_ASSERTS
|
||||
|
||||
|
|
|
@ -1228,6 +1228,9 @@ namespace libtorrent
|
|||
#endif
|
||||
;
|
||||
session_interface& m_ses;
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
tracker_logger& operator=(tracker_logger const&);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -623,7 +623,16 @@ int snprintf(char* buf, int len, char const* fmt, ...)
|
|||
#endif
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER <= 1200
|
||||
#define for if (false) {} else for
|
||||
// this is here to provide a standard-conforming for
|
||||
// keyword for old versions of msvc. The pragmas are
|
||||
// there to silence the warning it produces by using
|
||||
// a constant as conditional
|
||||
#define for \
|
||||
__pragma( warning(push) ) \
|
||||
__pragma( warning(disable:4127) ) \
|
||||
if (false) {} else \
|
||||
__pragma( warning(pop) )
|
||||
for
|
||||
#endif
|
||||
|
||||
#if TORRENT_BROKEN_UNIONS
|
||||
|
|
|
@ -111,6 +111,9 @@ namespace libtorrent
|
|||
{ return m_buf == 0? 0: &disk_buffer_holder::release; }
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
disk_buffer_holder& operator=(disk_buffer_holder const&);
|
||||
|
||||
buffer_allocator_interface& m_allocator;
|
||||
char* m_buf;
|
||||
block_cache_reference m_ref;
|
||||
|
|
|
@ -129,6 +129,8 @@ public:
|
|||
void send_name_lookup(boost::shared_ptr<handler_type> h);
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
i2p_stream& operator=(i2p_stream const&);
|
||||
|
||||
void do_connect(error_code const& e, tcp::resolver::iterator i
|
||||
, boost::shared_ptr<handler_type> h);
|
||||
|
@ -185,6 +187,8 @@ public:
|
|||
void async_name_lookup(char const* name, name_lookup_handler handler);
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
i2p_connection& operator=(i2p_connection const&);
|
||||
|
||||
void on_sam_connect(error_code const& ec, i2p_stream::handler_type const& h
|
||||
, boost::shared_ptr<i2p_stream>);
|
||||
|
|
|
@ -78,10 +78,9 @@ namespace libtorrent
|
|||
|
||||
#define INVARIANT_CHECK \
|
||||
invariant_checker const& _invariant_check = make_invariant_checker(*this); \
|
||||
(void)_invariant_check; \
|
||||
do {} while (false)
|
||||
(void)_invariant_check
|
||||
#else
|
||||
#define INVARIANT_CHECK do {} while (false)
|
||||
#define INVARIANT_CHECK do {} TORRENT_WHILE_0
|
||||
#endif
|
||||
|
||||
#endif // TORRENT_INVARIANT_ACCESS_HPP_INCLUDED
|
||||
|
|
|
@ -58,6 +58,9 @@ struct msg
|
|||
// the address of the process sending or receiving
|
||||
// the message.
|
||||
udp::endpoint addr;
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
msg& operator=(msg const&);
|
||||
};
|
||||
|
||||
} }
|
||||
|
|
|
@ -147,6 +147,9 @@ namespace libtorrent
|
|||
piece_block const& block;
|
||||
bool operator()(pending_block const& pb) const
|
||||
{ return pb.block == block; }
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
has_block& operator=(has_block const&);
|
||||
};
|
||||
|
||||
// argument pack passed to peer_connection constructor
|
||||
|
@ -257,6 +260,9 @@ namespace libtorrent
|
|||
// when this is set, the transfer stats for this connection
|
||||
// is not included in the torrent or session stats
|
||||
bool m_ignore_stats:1;
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
peer_connection_hot_members& operator=(peer_connection_hot_members const&);
|
||||
};
|
||||
|
||||
class TORRENT_EXTRA_EXPORT peer_connection
|
||||
|
@ -805,6 +811,8 @@ namespace libtorrent
|
|||
virtual int timeout() const;
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
peer_connection& operator=(peer_connection const&);
|
||||
|
||||
void do_update_interest();
|
||||
int preferred_caching() const;
|
||||
|
|
|
@ -138,6 +138,9 @@ struct receive_buffer
|
|||
#endif
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
receive_buffer& operator=(receive_buffer const&);
|
||||
|
||||
// recv_buf.begin (start of actual receive buffer)
|
||||
// |
|
||||
// | m_recv_start (logical start of current
|
||||
|
@ -263,6 +266,9 @@ struct crypto_receive_buffer
|
|||
, std::size_t bytes_transfered);
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
crypto_receive_buffer& operator=(crypto_receive_buffer const&);
|
||||
|
||||
int m_recv_pos;
|
||||
int m_packet_size;
|
||||
int m_soft_packet_size;
|
||||
|
|
|
@ -233,8 +233,12 @@ namespace libtorrent
|
|||
void load_state(bdecode_node const& rd);
|
||||
void save_state(entry& rd) const;
|
||||
|
||||
// private:
|
||||
private:
|
||||
friend struct aux::session_impl;
|
||||
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
feed& operator=(feed const&);
|
||||
|
||||
void add_item(feed_item const& item);
|
||||
|
||||
feed_handle my_handle();
|
||||
|
@ -257,9 +261,9 @@ namespace libtorrent
|
|||
std::map<std::string, time_t> m_added;
|
||||
|
||||
std::string m_title;
|
||||
std::string m_description;
|
||||
std::string m_description;
|
||||
time_t m_last_attempt;
|
||||
time_t m_last_update;
|
||||
time_t m_last_update;
|
||||
// refresh rate of this feed in minutes
|
||||
int m_ttl;
|
||||
// the number of update failures in a row
|
||||
|
|
|
@ -289,6 +289,8 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
socket_type& operator=(socket_type const&);
|
||||
|
||||
void destruct();
|
||||
void construct(int type, void* userdata);
|
||||
|
@ -316,6 +318,8 @@ namespace libtorrent
|
|||
>::value
|
||||
};
|
||||
|
||||
// TODO: 2 it would be nice to use aligned_storage here when
|
||||
// building on c++11
|
||||
boost::int64_t m_data[(storage_size + sizeof(boost::int64_t) - 1)
|
||||
/ sizeof(boost::int64_t)];
|
||||
};
|
||||
|
|
|
@ -198,6 +198,8 @@ namespace libtorrent
|
|||
ipv4_peer(tcp::endpoint const& ip, bool connectable, int src);
|
||||
|
||||
address_v4 addr;
|
||||
private:
|
||||
ipv4_peer& operator=(ipv4_peer const&);
|
||||
};
|
||||
|
||||
#if TORRENT_USE_I2P
|
||||
|
@ -207,6 +209,8 @@ namespace libtorrent
|
|||
~i2p_peer();
|
||||
|
||||
char* destination;
|
||||
private:
|
||||
i2p_peer& operator=(i2p_peer const&);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -216,6 +220,9 @@ namespace libtorrent
|
|||
ipv6_peer(tcp::endpoint const& ip, bool connectable, int src);
|
||||
|
||||
const address_v6::bytes_type addr;
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
ipv6_peer& operator=(ipv6_peer const&);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -101,6 +101,9 @@ namespace libtorrent
|
|||
void inc_stats_counter(int counter, int delta = 1);
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
utp_socket_manager& operator=(utp_socket_manager const&);
|
||||
|
||||
udp_socket& m_sock;
|
||||
incoming_utp_callback_t m_cb;
|
||||
|
||||
|
|
|
@ -465,6 +465,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
utp_stream& operator=(utp_stream const&);
|
||||
|
||||
void cancel_handlers(error_code const&);
|
||||
|
||||
|
|
|
@ -692,7 +692,7 @@ namespace libtorrent
|
|||
ec = make_error_code(code); \
|
||||
if (error_pos) *error_pos = start - orig_start; \
|
||||
goto done; \
|
||||
} while (false)
|
||||
} TORRENT_WHILE_0
|
||||
|
||||
int bdecode(char const* start, char const* end, bdecode_node& ret
|
||||
, error_code& ec, int* error_pos, int depth_limit, int token_limit)
|
||||
|
|
|
@ -280,10 +280,10 @@ const char* const job_action_name[] =
|
|||
|
||||
|
||||
#define TORRENT_PIECE_ASSERT(cond, piece) \
|
||||
do { if (!(cond)) { assert_print_piece(piece); assert_fail(#cond, __LINE__, __FILE__, TORRENT_FUNCTION, 0); } } while(false)
|
||||
do { if (!(cond)) { assert_print_piece(piece); assert_fail(#cond, __LINE__, __FILE__, TORRENT_FUNCTION, 0); } } TORRENT_WHILE_0
|
||||
|
||||
#else
|
||||
#define TORRENT_PIECE_ASSERT(cond, piece) do {} while(false)
|
||||
#define TORRENT_PIECE_ASSERT(cond, piece) do {} TORRENT_WHILE_0
|
||||
#endif
|
||||
|
||||
cached_piece_entry::cached_piece_entry()
|
||||
|
|
|
@ -60,7 +60,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#define DEBUG_DISK_THREAD 0
|
||||
|
||||
#define DLOG if (DEBUG_DISK_THREAD) debug_log
|
||||
#if DEBUG_DISK_THREAD
|
||||
#define DLOG debug_log
|
||||
#else
|
||||
#define DLOG TORRENT_WHILE_0 debug_log
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
@ -73,10 +77,10 @@ namespace libtorrent
|
|||
#if TORRENT_USE_ASSERTS
|
||||
|
||||
#define TORRENT_PIECE_ASSERT(cond, piece) \
|
||||
do { if (!(cond)) { assert_print_piece(piece); assert_fail(#cond, __LINE__, __FILE__, TORRENT_FUNCTION, 0); } } while(false)
|
||||
do { if (!(cond)) { assert_print_piece(piece); assert_fail(#cond, __LINE__, __FILE__, TORRENT_FUNCTION, 0); } } TORRENT_WHILE_0
|
||||
|
||||
#else
|
||||
#define TORRENT_PIECE_ASSERT(cond, piece) do {} while(false)
|
||||
#define TORRENT_PIECE_ASSERT(cond, piece) do {} TORRENT_WHILE_0
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -50,10 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/hex.hpp"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define for if (false) {} else for
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class T>
|
||||
|
|
|
@ -785,6 +785,10 @@ struct immutable_item_comparator
|
|||
return lhs.second.num_announcers / 5 - l_distance < rhs.second.num_announcers / 5 - r_distance;
|
||||
}
|
||||
|
||||
private:
|
||||
// explicitly disallow assignment, to silence msvc warning
|
||||
immutable_item_comparator& operator=(immutable_item_comparator const&);
|
||||
|
||||
node_id const& m_our_id;
|
||||
};
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace libtorrent
|
|||
return -1;
|
||||
}
|
||||
|
||||
#define TORRENT_FAIL_BDECODE(code) do { ec = make_error_code(code); return fail(error_pos, stack, start, orig_start); } while (false)
|
||||
#define TORRENT_FAIL_BDECODE(code) do { ec = make_error_code(code); return fail(error_pos, stack, start, orig_start); } TORRENT_WHILE_0
|
||||
|
||||
bool numeric(char c) { return c >= '0' && c <= '9'; }
|
||||
|
||||
|
|
|
@ -90,8 +90,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define DEBUG_STORAGE 0
|
||||
#define DEBUG_DELETE_FILES 0
|
||||
|
||||
#define DLOG if (DEBUG_STORAGE) fprintf
|
||||
#define DFLOG if (DEBUG_DELETE_FILES) fprintf
|
||||
#if DEBUG_STORAGE
|
||||
#define DLOG fprintf
|
||||
#else
|
||||
#define DLOG TORRENT_WHILE_0 fprintf
|
||||
#endif
|
||||
|
||||
#if DEBUG_DELETE_FILES
|
||||
#define DFLOG fprintf
|
||||
#else
|
||||
#define DFLOG TORRENT_WHILE_0 fprintf
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
|
|
@ -123,7 +123,7 @@ udp_socket::~udp_socket()
|
|||
int& m;
|
||||
};
|
||||
#else
|
||||
#define CHECK_MAGIC do {} while (false)
|
||||
#define CHECK_MAGIC do {} TORRENT_WHILE_0
|
||||
#endif
|
||||
|
||||
void udp_socket::send_hostname(char const* hostname, int port
|
||||
|
|
|
@ -47,6 +47,10 @@ namespace libtorrent
|
|||
wchar_t const* dst_start = wide.c_str();
|
||||
char const* src_start = utf8.c_str();
|
||||
ConversionResult ret;
|
||||
// TODO: 3 refactor this to use wchar_t as a template
|
||||
// it would cause less code to be generated without
|
||||
// relying on dead-code elimination and fix msvc constant
|
||||
// expression warning
|
||||
if (sizeof(wchar_t) == sizeof(UTF32))
|
||||
{
|
||||
ret = ConvertUTF8toUTF32((const UTF8**)&src_start, (const UTF8*)src_start
|
||||
|
|
|
@ -89,13 +89,13 @@ void utp_log(char const* fmt, ...)
|
|||
#if TORRENT_VERBOSE_UTP_LOG
|
||||
#define UTP_LOGV utp_log
|
||||
#else
|
||||
#define UTP_LOGV if (false) printf
|
||||
#define UTP_LOGV TORRENT_WHILE_0 printf
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define UTP_LOG if (false) printf
|
||||
#define UTP_LOGV if (false) printf
|
||||
#define UTP_LOG TORRENT_WHILE_0 printf
|
||||
#define UTP_LOGV TORRENT_WHILE_0 printf
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue