diff --git a/Jamfile b/Jamfile index c55548e12..80824131e 100755 --- a/Jamfile +++ b/Jamfile @@ -225,6 +225,33 @@ rule linking ( properties * ) return $(result) ; } +rule warnings ( properties * ) +{ + local result ; + if clang in $(properties) + || darwin in $(properties) + { + result += -Weverything ; + result += -Wno-documentation ; + result += -Wno-c++98-compat-pedantic ; + result += -Wno-padded ; + result += -Wno-global-constructors ; + result += -Wno-c++98-compat ; + result += -Wno-exit-time-destructors ; + result += -Wno-documentation-unknown-command ; + result += -Wno-disabled-macro-expansion ; + } + + if msvc in $(properties) + { +# disable warning C4503: decorated name length exceeded, name was truncated + result += /wd4503 ; + result += /W4 ; + } + + return $(result) ; +} + # rule for adding the right source files # depending on target-os and features rule building ( properties * ) @@ -679,26 +706,10 @@ local usage-requirements = # these compiler settings just makes the compiler standard conforming msvc:/Zc:wchar_t msvc:/Zc:forScope -# disable bogus deprecation warnings on msvc8 - msvc:_SCL_SECURE_NO_DEPRECATE - msvc:_CRT_SECURE_NO_DEPRECATE # msvc optimizations msvc,release:/OPT:ICF=5 msvc,release:/OPT:REF -# disable warning C4503: decorated name length exceeded, name was truncated - msvc:/wd4503 -# disable warning C4275: non-dll interface class 'x' used as base for dll-interface struct 'y' - msvc:/wd4275 -# disable warning C4251: 'x' needs to have dll-interface to be used by clients of class 'y' - msvc:/wd4251 -# disable some warnings for gcc - gcc:-fno-strict-aliasing - gcc:-Wno-missing-braces - gcc:-Wno-unused-local-typedefs -# suppress warnings caused by boost using c++11 features even when not -# in c++11 mode - darwin:-Wno-c++11-extensions -# assert on integer overflow + system:$(CXXFLAGS) system:$(LDFLAGS) # this works around a bug in asio in boost-1.39 @@ -736,19 +747,22 @@ lib torrent logging:ed25519/src/$(ED25519_SOURCES).cpp @building + @warnings system:$(CXXFLAGS) + # disable bogus deprecation warnings on msvc8 + msvc:_SCL_SECURE_NO_DEPRECATE + msvc:_CRT_SECURE_NO_DEPRECATE + $(usage-requirements) : # default build static multi - all : # usage requirements $(usage-requirements) shared:TORRENT_LINKING_SHARED - ; headers = [ path.glob-tree include/libtorrent : *.hpp ] ; diff --git a/examples/print.cpp b/examples/print.cpp index e4e065288..eb1f6e786 100644 --- a/examples/print.cpp +++ b/examples/print.cpp @@ -50,7 +50,7 @@ std::string to_string(int v, int width) std::string add_suffix(float val, char const* suffix) { - if (val == 0) + if (val < 0.001f) { std::string ret; ret.resize(4 + 2, ' '); @@ -85,7 +85,7 @@ std::string const& progress_bar(int progress, int width, color_code c { static std::string bar; bar.clear(); - bar.reserve(width + 10); + bar.reserve(size_t(width + 10)); int progress_chars = (progress * width + 500) / 1000; @@ -105,7 +105,7 @@ std::string const& progress_bar(int progress, int width, color_code c if (c == col_black || c == col_blue) tc = col_white; - caption.resize(width, ' '); + caption.resize(size_t(width), ' '); char str[256]; if (flags & progress_invert) @@ -180,7 +180,7 @@ void terminal_size(int* terminal_width, int* terminal_height) #else int tty = open("/dev/tty", O_RDONLY); winsize size; - int ret = ioctl(tty, TIOCGWINSZ, (char*)&size); + int ret = ioctl(tty, TIOCGWINSZ, reinterpret_cast(&size)); close(tty); if (ret == 0) { diff --git a/examples/print.hpp b/examples/print.hpp index 794c8181e..7ac9e2045 100644 --- a/examples/print.hpp +++ b/examples/print.hpp @@ -13,7 +13,7 @@ enum color_code col_blue = 4, col_magenta = 5, col_cyan = 6, - col_white = 7, + col_white = 7 }; char const* esc(char const* code); diff --git a/include/libtorrent/address.hpp b/include/libtorrent/address.hpp index 1a7aa4cc3..a68c1ff84 100644 --- a/include/libtorrent/address.hpp +++ b/include/libtorrent/address.hpp @@ -36,6 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" +#include "aux_/disable_warnings_push.hpp" + #ifdef __OBJC__ #define Protocol Protocol_ #endif @@ -51,6 +53,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include "aux_/disable_warnings_pop.hpp" + #ifdef __OBJC__ #undef Protocol #endif diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 6551bab02..fc0802873 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -38,9 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include @@ -48,6 +46,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "aux_/disable_warnings_pop.hpp" + // OVERVIEW // // The pop_alerts() function on session is the main interface for retrieving @@ -74,10 +74,6 @@ POSSIBILITY OF SUCH DAMAGE. // call to pop_alerts(). Internal members of alerts also become invalid once // pop_alerts() is called again. -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #include "libtorrent/time.hpp" #include "libtorrent/config.hpp" @@ -273,7 +269,7 @@ namespace libtorrent { #ifndef BOOST_NO_EXCEPTIONS #ifndef TORRENT_NO_DEPRECATE - struct TORRENT_EXPORT unhandled_alert : std::exception + struct TORRENT_DEPRECATED TORRENT_EXPORT unhandled_alert : std::exception { unhandled_alert() {} }; @@ -286,6 +282,7 @@ namespace libtorrent { template + TORRENT_DEPRECATED void handle_alert_dispatch( const std::auto_ptr& alert_, const Handler& handler , const std::type_info& typeid_ @@ -296,10 +293,11 @@ namespace libtorrent { else handle_alert_dispatch(alert_, handler, typeid_ , BOOST_PP_ENUM_SHIFTED_PARAMS( - TORRENT_MAX_ALERT_TYPES, p), (void_*)0); + TORRENT_MAX_ALERT_TYPES, p), reinterpret_cast(0)); } template + TORRENT_DEPRECATED void handle_alert_dispatch( const std::auto_ptr& , const Handler& @@ -313,13 +311,13 @@ namespace libtorrent { template - struct TORRENT_EXPORT handle_alert + struct TORRENT_DEPRECATED TORRENT_EXPORT handle_alert { template handle_alert(const std::auto_ptr& alert_ , const Handler& handler) { - #define ALERT_POINTER_TYPE(z, n, text) (BOOST_PP_CAT(T, n)*)0 + #define ALERT_POINTER_TYPE(z, n, text) reinterpret_cast(0) detail::handle_alert_dispatch(alert_, handler, typeid(*alert_) , BOOST_PP_ENUM(TORRENT_MAX_ALERT_TYPES, ALERT_POINTER_TYPE, _)); diff --git a/include/libtorrent/alert_manager.hpp b/include/libtorrent/alert_manager.hpp index 033eda39c..9aa6df7a6 100644 --- a/include/libtorrent/alert_manager.hpp +++ b/include/libtorrent/alert_manager.hpp @@ -39,6 +39,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/heterogeneous_queue.hpp" #include "libtorrent/stack_allocator.hpp" +#include "aux_/disable_warnings_push.hpp" + #ifndef TORRENT_NO_DEPRECATE #include #endif @@ -47,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for std::forward +#include "aux_/disable_warnings_pop.hpp" + // used for emplace_alert() variadic template emulation for c++98 #define TORRENT_ALERT_MANAGER_MAX_ARITY 7 diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 6fa9f2e5f..ac1f2eda3 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -166,7 +166,7 @@ namespace libtorrent // internal torrent_added_alert(aux::stack_allocator& alloc, torrent_handle const& h); - TORRENT_DEFINE_ALERT(torrent_added_alert, 3); + TORRENT_DEFINE_ALERT(torrent_added_alert, 3) static const int static_category = alert::status_notification; virtual std::string message() const; }; @@ -189,7 +189,7 @@ namespace libtorrent torrent_removed_alert(aux::stack_allocator& alloc , torrent_handle const& h, sha1_hash const& ih); - TORRENT_DEFINE_ALERT_PRIO(torrent_removed_alert, 4); + TORRENT_DEFINE_ALERT_PRIO(torrent_removed_alert, 4) static const int static_category = alert::status_notification; virtual std::string message() const; #ifndef TORRENT_NO_DEPRECATE @@ -213,7 +213,7 @@ namespace libtorrent , int p, boost::shared_array d, int s); read_piece_alert(aux::stack_allocator& alloc, torrent_handle h, int p, error_code e); - TORRENT_DEFINE_ALERT_PRIO(read_piece_alert, 5); + TORRENT_DEFINE_ALERT_PRIO(read_piece_alert, 5) static const int static_category = alert::storage_notification; virtual std::string message() const; @@ -235,7 +235,7 @@ namespace libtorrent file_completed_alert(aux::stack_allocator& alloc, torrent_handle const& h , int idx); - TORRENT_DEFINE_ALERT(file_completed_alert, 6); + TORRENT_DEFINE_ALERT(file_completed_alert, 6) static const int static_category = alert::progress_notification; virtual std::string message() const; @@ -253,7 +253,7 @@ namespace libtorrent , std::string const& n , int idx); - TORRENT_DEFINE_ALERT_PRIO(file_renamed_alert, 7); + TORRENT_DEFINE_ALERT_PRIO(file_renamed_alert, 7) static const int static_category = alert::storage_notification; virtual std::string message() const; @@ -280,7 +280,7 @@ namespace libtorrent , torrent_handle const& h, int idx , error_code ec); - TORRENT_DEFINE_ALERT_PRIO(file_rename_failed_alert, 8); + TORRENT_DEFINE_ALERT_PRIO(file_rename_failed_alert, 8) static const int static_category = alert::storage_notification; @@ -384,7 +384,7 @@ namespace libtorrent performance_alert(aux::stack_allocator& alloc, torrent_handle const& h , performance_warning_t w); - TORRENT_DEFINE_ALERT(performance_alert, 9); + TORRENT_DEFINE_ALERT(performance_alert, 9) static const int static_category = alert::performance_warning; @@ -401,7 +401,7 @@ namespace libtorrent , torrent_status::state_t st , torrent_status::state_t prev_st); - TORRENT_DEFINE_ALERT(state_changed_alert, 10); + TORRENT_DEFINE_ALERT(state_changed_alert, 10) static const int static_category = alert::status_notification; @@ -433,7 +433,7 @@ namespace libtorrent , error_code const& e , std::string const& m); - TORRENT_DEFINE_ALERT(tracker_error_alert, 11); + TORRENT_DEFINE_ALERT(tracker_error_alert, 11) static const int static_category = alert::tracker_notification | alert::error_notification; virtual std::string message() const; @@ -463,7 +463,7 @@ namespace libtorrent , std::string const& u , std::string const& m); - TORRENT_DEFINE_ALERT(tracker_warning_alert, 12); + TORRENT_DEFINE_ALERT(tracker_warning_alert, 12) static const int static_category = alert::tracker_notification | alert::error_notification; virtual std::string message() const; @@ -490,7 +490,7 @@ namespace libtorrent , int comp , std::string const& u); - TORRENT_DEFINE_ALERT(scrape_reply_alert, 13); + TORRENT_DEFINE_ALERT(scrape_reply_alert, 13) virtual std::string message() const; @@ -515,7 +515,7 @@ namespace libtorrent , std::string const& u , std::string const& m); - TORRENT_DEFINE_ALERT(scrape_failed_alert, 14); + TORRENT_DEFINE_ALERT(scrape_failed_alert, 14) static const int static_category = alert::tracker_notification | alert::error_notification; virtual std::string message() const; @@ -549,7 +549,7 @@ namespace libtorrent , int np , std::string const& u); - TORRENT_DEFINE_ALERT(tracker_reply_alert, 15); + TORRENT_DEFINE_ALERT(tracker_reply_alert, 15) virtual std::string message() const; @@ -570,7 +570,7 @@ namespace libtorrent , torrent_handle const& h , int np); - TORRENT_DEFINE_ALERT(dht_reply_alert, 16); + TORRENT_DEFINE_ALERT(dht_reply_alert, 16) virtual std::string message() const; @@ -587,7 +587,7 @@ namespace libtorrent , torrent_handle const& h , std::string const& u, int e); - TORRENT_DEFINE_ALERT(tracker_announce_alert, 17); + TORRENT_DEFINE_ALERT(tracker_announce_alert, 17) virtual std::string message() const; @@ -608,7 +608,7 @@ namespace libtorrent hash_failed_alert(aux::stack_allocator& alloc, torrent_handle const& h , int index); - TORRENT_DEFINE_ALERT(hash_failed_alert, 18); + TORRENT_DEFINE_ALERT(hash_failed_alert, 18) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -624,7 +624,7 @@ namespace libtorrent peer_ban_alert(aux::stack_allocator& alloc, torrent_handle h , tcp::endpoint const& ep, peer_id const& peer_id); - TORRENT_DEFINE_ALERT(peer_ban_alert, 19); + TORRENT_DEFINE_ALERT(peer_ban_alert, 19) virtual std::string message() const; }; @@ -637,7 +637,7 @@ namespace libtorrent peer_unsnubbed_alert(aux::stack_allocator& alloc, torrent_handle h , tcp::endpoint const& ep, peer_id const& peer_id); - TORRENT_DEFINE_ALERT(peer_unsnubbed_alert, 20); + TORRENT_DEFINE_ALERT(peer_unsnubbed_alert, 20) virtual std::string message() const; }; @@ -650,7 +650,7 @@ namespace libtorrent peer_snubbed_alert(aux::stack_allocator& alloc, torrent_handle h , tcp::endpoint const& ep, peer_id const& peer_id); - TORRENT_DEFINE_ALERT(peer_snubbed_alert, 21); + TORRENT_DEFINE_ALERT(peer_snubbed_alert, 21) virtual std::string message() const; }; @@ -664,7 +664,7 @@ namespace libtorrent , tcp::endpoint const& ep, peer_id const& peer_id, int op , error_code const& e); - TORRENT_DEFINE_ALERT(peer_error_alert, 22); + TORRENT_DEFINE_ALERT(peer_error_alert, 22) static const int static_category = alert::peer_notification; virtual std::string message() const; @@ -688,7 +688,7 @@ namespace libtorrent peer_connect_alert(aux::stack_allocator& alloc, torrent_handle h , tcp::endpoint const& ep, peer_id const& peer_id, int type); - TORRENT_DEFINE_ALERT(peer_connect_alert, 23); + TORRENT_DEFINE_ALERT(peer_connect_alert, 23) static const int static_category = alert::debug_notification; virtual std::string message() const; @@ -706,7 +706,7 @@ namespace libtorrent , peer_id const& peer_id, operation_t op, int type, error_code const& e , close_reason_t r); - TORRENT_DEFINE_ALERT(peer_disconnected_alert, 24); + TORRENT_DEFINE_ALERT(peer_disconnected_alert, 24) static const int static_category = alert::debug_notification; virtual std::string message() const; @@ -740,7 +740,7 @@ namespace libtorrent , peer_id const& peer_id, peer_request const& r , bool we_have, bool peer_interested, bool withheld); - TORRENT_DEFINE_ALERT(invalid_request_alert, 25); + TORRENT_DEFINE_ALERT(invalid_request_alert, 25) virtual std::string message() const; @@ -768,7 +768,7 @@ namespace libtorrent torrent_finished_alert(aux::stack_allocator& alloc, torrent_handle h); - TORRENT_DEFINE_ALERT(torrent_finished_alert, 26); + TORRENT_DEFINE_ALERT(torrent_finished_alert, 26) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -783,7 +783,7 @@ namespace libtorrent piece_finished_alert(aux::stack_allocator& alloc, torrent_handle const& h, int piece_num); - TORRENT_DEFINE_ALERT(piece_finished_alert, 27); + TORRENT_DEFINE_ALERT(piece_finished_alert, 27) static const int static_category = alert::progress_notification; virtual std::string message() const; @@ -800,7 +800,7 @@ namespace libtorrent , tcp::endpoint const& ep, peer_id const& peer_id, int block_num , int piece_num); - TORRENT_DEFINE_ALERT(request_dropped_alert, 28); + TORRENT_DEFINE_ALERT(request_dropped_alert, 28) static const int static_category = alert::progress_notification | alert::peer_notification; @@ -818,7 +818,7 @@ namespace libtorrent , tcp::endpoint const& ep, peer_id const& peer_id, int block_num , int piece_num); - TORRENT_DEFINE_ALERT(block_timeout_alert, 29); + TORRENT_DEFINE_ALERT(block_timeout_alert, 29) static const int static_category = alert::progress_notification | alert::peer_notification; @@ -836,7 +836,7 @@ namespace libtorrent , tcp::endpoint const& ep, peer_id const& peer_id, int block_num , int piece_num); - TORRENT_DEFINE_ALERT(block_finished_alert, 30); + TORRENT_DEFINE_ALERT(block_finished_alert, 30) static const int static_category = alert::progress_notification; virtual std::string message() const; @@ -853,7 +853,7 @@ namespace libtorrent , tcp::endpoint const& ep , peer_id const& peer_id, int block_num, int piece_num); - TORRENT_DEFINE_ALERT(block_downloading_alert, 31); + TORRENT_DEFINE_ALERT(block_downloading_alert, 31) static const int static_category = alert::progress_notification; virtual std::string message() const; @@ -874,7 +874,7 @@ namespace libtorrent , tcp::endpoint const& ep , peer_id const& peer_id, int block_num, int piece_num); - TORRENT_DEFINE_ALERT(unwanted_block_alert, 32); + TORRENT_DEFINE_ALERT(unwanted_block_alert, 32) virtual std::string message() const; @@ -892,7 +892,7 @@ namespace libtorrent storage_moved_alert(aux::stack_allocator& alloc , torrent_handle const& h, std::string const& p); - TORRENT_DEFINE_ALERT(storage_moved_alert, 33); + TORRENT_DEFINE_ALERT(storage_moved_alert, 33) static const int static_category = alert::storage_notification; virtual std::string message() const; @@ -919,7 +919,7 @@ namespace libtorrent , std::string const& file , char const* op); - TORRENT_DEFINE_ALERT(storage_moved_failed_alert, 34); + TORRENT_DEFINE_ALERT(storage_moved_failed_alert, 34) static const int static_category = alert::storage_notification; virtual std::string message() const; @@ -956,7 +956,7 @@ namespace libtorrent torrent_deleted_alert(aux::stack_allocator& alloc , torrent_handle const& h, sha1_hash const& ih); - TORRENT_DEFINE_ALERT_PRIO(torrent_deleted_alert, 35); + TORRENT_DEFINE_ALERT_PRIO(torrent_deleted_alert, 35) static const int static_category = alert::storage_notification; virtual std::string message() const; @@ -976,7 +976,7 @@ namespace libtorrent torrent_delete_failed_alert(aux::stack_allocator& alloc , torrent_handle const& h, error_code const& e, sha1_hash const& ih); - TORRENT_DEFINE_ALERT_PRIO(torrent_delete_failed_alert, 36); + TORRENT_DEFINE_ALERT_PRIO(torrent_delete_failed_alert, 36) static const int static_category = alert::storage_notification | alert::error_notification; @@ -1006,7 +1006,7 @@ namespace libtorrent , boost::shared_ptr const& rd , torrent_handle const& h); - TORRENT_DEFINE_ALERT_PRIO(save_resume_data_alert, 37); + TORRENT_DEFINE_ALERT_PRIO(save_resume_data_alert, 37) static const int static_category = alert::storage_notification; virtual std::string message() const; @@ -1027,7 +1027,7 @@ namespace libtorrent save_resume_data_failed_alert(aux::stack_allocator& alloc , torrent_handle const& h, error_code const& e); - TORRENT_DEFINE_ALERT_PRIO(save_resume_data_failed_alert, 38); + TORRENT_DEFINE_ALERT_PRIO(save_resume_data_failed_alert, 38) static const int static_category = alert::storage_notification | alert::error_notification; @@ -1053,7 +1053,7 @@ namespace libtorrent // internal torrent_paused_alert(aux::stack_allocator& alloc, torrent_handle const& h); - TORRENT_DEFINE_ALERT(torrent_paused_alert, 39); + TORRENT_DEFINE_ALERT(torrent_paused_alert, 39) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1066,7 +1066,7 @@ namespace libtorrent // internal torrent_resumed_alert(aux::stack_allocator& alloc, torrent_handle const& h); - TORRENT_DEFINE_ALERT(torrent_resumed_alert, 40); + TORRENT_DEFINE_ALERT(torrent_resumed_alert, 40) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1079,7 +1079,7 @@ namespace libtorrent // internal torrent_checked_alert(aux::stack_allocator& alloc, torrent_handle const& h); - TORRENT_DEFINE_ALERT(torrent_checked_alert, 41); + TORRENT_DEFINE_ALERT(torrent_checked_alert, 41) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1094,7 +1094,7 @@ namespace libtorrent url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h , std::string const& u, std::string const& m); - TORRENT_DEFINE_ALERT(url_seed_alert, 42); + TORRENT_DEFINE_ALERT(url_seed_alert, 42) static const int static_category = alert::peer_notification | alert::error_notification; std::string message() const; @@ -1134,7 +1134,7 @@ namespace libtorrent , char const* op , torrent_handle const& h); - TORRENT_DEFINE_ALERT(file_error_alert, 43); + TORRENT_DEFINE_ALERT(file_error_alert, 43) static const int static_category = alert::status_notification | alert::error_notification @@ -1170,7 +1170,7 @@ namespace libtorrent metadata_failed_alert(aux::stack_allocator& alloc , torrent_handle const& h, error_code const& ec); - TORRENT_DEFINE_ALERT(metadata_failed_alert, 44); + TORRENT_DEFINE_ALERT(metadata_failed_alert, 44) static const int static_category = alert::error_notification; virtual std::string message() const; @@ -1210,7 +1210,7 @@ namespace libtorrent metadata_received_alert(aux::stack_allocator& alloc , torrent_handle const& h); - TORRENT_DEFINE_ALERT(metadata_received_alert, 45); + TORRENT_DEFINE_ALERT(metadata_received_alert, 45) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1227,7 +1227,7 @@ namespace libtorrent , udp::endpoint const& ep , error_code const& ec); - TORRENT_DEFINE_ALERT(udp_error_alert, 46); + TORRENT_DEFINE_ALERT(udp_error_alert, 46) static const int static_category = alert::error_notification; virtual std::string message() const; @@ -1248,7 +1248,7 @@ namespace libtorrent // internal external_ip_alert(aux::stack_allocator& alloc, address const& ip); - TORRENT_DEFINE_ALERT(external_ip_alert, 47); + TORRENT_DEFINE_ALERT(external_ip_alert, 47) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1278,7 +1278,7 @@ namespace libtorrent , error_code const& ec , socket_type_t t); - TORRENT_DEFINE_ALERT_PRIO(listen_failed_alert, 48); + TORRENT_DEFINE_ALERT_PRIO(listen_failed_alert, 48) static const int static_category = alert::status_notification | alert::error_notification; virtual std::string message() const; @@ -1321,7 +1321,7 @@ namespace libtorrent listen_succeeded_alert(aux::stack_allocator& alloc, tcp::endpoint const& ep , socket_type_t t); - TORRENT_DEFINE_ALERT_PRIO(listen_succeeded_alert, 49); + TORRENT_DEFINE_ALERT_PRIO(listen_succeeded_alert, 49) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1349,7 +1349,7 @@ namespace libtorrent portmap_error_alert(aux::stack_allocator& alloc, int i, int t , error_code const& e); - TORRENT_DEFINE_ALERT(portmap_error_alert, 50); + TORRENT_DEFINE_ALERT(portmap_error_alert, 50) static const int static_category = alert::port_mapping_notification | alert::error_notification; @@ -1378,7 +1378,7 @@ namespace libtorrent // internal portmap_alert(aux::stack_allocator& alloc, int i, int port, int t); - TORRENT_DEFINE_ALERT(portmap_alert, 51); + TORRENT_DEFINE_ALERT(portmap_alert, 51) static const int static_category = alert::port_mapping_notification; virtual std::string message() const; @@ -1403,7 +1403,7 @@ namespace libtorrent // internal portmap_log_alert(aux::stack_allocator& alloc, int t, const char* m); - TORRENT_DEFINE_ALERT(portmap_log_alert, 52); + TORRENT_DEFINE_ALERT(portmap_log_alert, 52) static const int static_category = alert::port_mapping_notification; virtual std::string message() const; @@ -1437,7 +1437,7 @@ namespace libtorrent , std::string const& file , char const* op); - TORRENT_DEFINE_ALERT(fastresume_rejected_alert, 53); + TORRENT_DEFINE_ALERT(fastresume_rejected_alert, 53) static const int static_category = alert::status_notification | alert::error_notification; @@ -1478,7 +1478,7 @@ namespace libtorrent peer_blocked_alert(aux::stack_allocator& alloc, torrent_handle const& h , address const& i, int r); - TORRENT_DEFINE_ALERT(peer_blocked_alert, 54); + TORRENT_DEFINE_ALERT(peer_blocked_alert, 54) static const int static_category = alert::ip_block_notification; virtual std::string message() const; @@ -1508,7 +1508,7 @@ namespace libtorrent dht_announce_alert(aux::stack_allocator& alloc, address const& i, int p , sha1_hash const& ih); - TORRENT_DEFINE_ALERT(dht_announce_alert, 55); + TORRENT_DEFINE_ALERT(dht_announce_alert, 55) static const int static_category = alert::dht_notification; virtual std::string message() const; @@ -1525,7 +1525,7 @@ namespace libtorrent // internal dht_get_peers_alert(aux::stack_allocator& alloc, sha1_hash const& ih); - TORRENT_DEFINE_ALERT(dht_get_peers_alert, 56); + TORRENT_DEFINE_ALERT(dht_get_peers_alert, 56) static const int static_category = alert::dht_notification; virtual std::string message() const; @@ -1542,7 +1542,7 @@ namespace libtorrent stats_alert(aux::stack_allocator& alloc, torrent_handle const& h, int interval , stat const& s); - TORRENT_DEFINE_ALERT(stats_alert, 57); + TORRENT_DEFINE_ALERT(stats_alert, 57) static const int static_category = alert::stats_notification; virtual std::string message() const; @@ -1593,7 +1593,7 @@ namespace libtorrent // internal cache_flushed_alert(aux::stack_allocator& alloc, torrent_handle const& h); - TORRENT_DEFINE_ALERT(cache_flushed_alert, 58); + TORRENT_DEFINE_ALERT(cache_flushed_alert, 58) static const int static_category = alert::storage_notification; }; @@ -1608,7 +1608,7 @@ namespace libtorrent anonymous_mode_alert(aux::stack_allocator& alloc, torrent_handle const& h , int k, std::string const& s); - TORRENT_DEFINE_ALERT(anonymous_mode_alert, 59); + TORRENT_DEFINE_ALERT(anonymous_mode_alert, 59) static const int static_category = alert::error_notification; virtual std::string message() const; @@ -1634,7 +1634,7 @@ namespace libtorrent lsd_peer_alert(aux::stack_allocator& alloc, torrent_handle const& h , tcp::endpoint const& i); - TORRENT_DEFINE_ALERT(lsd_peer_alert, 60); + TORRENT_DEFINE_ALERT(lsd_peer_alert, 60) static const int static_category = alert::peer_notification; virtual std::string message() const; @@ -1650,7 +1650,7 @@ namespace libtorrent , std::string const& u , const std::string& id); - TORRENT_DEFINE_ALERT(trackerid_alert, 61); + TORRENT_DEFINE_ALERT(trackerid_alert, 61) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1673,7 +1673,7 @@ namespace libtorrent // internal dht_bootstrap_alert(aux::stack_allocator& alloc); - TORRENT_DEFINE_ALERT(dht_bootstrap_alert, 62); + TORRENT_DEFINE_ALERT(dht_bootstrap_alert, 62) static const int static_category = alert::dht_notification; virtual std::string message() const; @@ -1691,7 +1691,7 @@ namespace libtorrent rss_alert(aux::stack_allocator& alloc, feed_handle h , std::string const& u, int s, error_code const& ec); - TORRENT_DEFINE_ALERT(rss_alert, 63); + TORRENT_DEFINE_ALERT(rss_alert, 63) static const int static_category = alert::rss_notification; virtual std::string message() const; @@ -1734,7 +1734,7 @@ namespace libtorrent torrent_error_alert(aux::stack_allocator& alloc, torrent_handle const& h , error_code const& e, std::string const& f); - TORRENT_DEFINE_ALERT(torrent_error_alert, 64); + TORRENT_DEFINE_ALERT(torrent_error_alert, 64) static const int static_category = alert::error_notification | alert::status_notification; virtual std::string message() const; @@ -1764,7 +1764,7 @@ namespace libtorrent torrent_need_cert_alert(aux::stack_allocator& alloc , torrent_handle const& h); - TORRENT_DEFINE_ALERT_PRIO(torrent_need_cert_alert, 65); + TORRENT_DEFINE_ALERT_PRIO(torrent_need_cert_alert, 65) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1787,7 +1787,7 @@ namespace libtorrent incoming_connection_alert(aux::stack_allocator& alloc, int t , tcp::endpoint const& i); - TORRENT_DEFINE_ALERT(incoming_connection_alert, 66); + TORRENT_DEFINE_ALERT(incoming_connection_alert, 66) static const int static_category = alert::peer_notification; virtual std::string message() const; @@ -1849,7 +1849,7 @@ namespace libtorrent : status(st) {} - TORRENT_DEFINE_ALERT_PRIO(state_update_alert, 68); + TORRENT_DEFINE_ALERT_PRIO(state_update_alert, 68) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1869,7 +1869,7 @@ namespace libtorrent { mmap_cache_alert(aux::stack_allocator& alloc , error_code const& ec): error(ec) {} - TORRENT_DEFINE_ALERT(mmap_cache_alert, 69); + TORRENT_DEFINE_ALERT(mmap_cache_alert, 69) static const int static_category = alert::error_notification; virtual std::string message() const; @@ -1884,7 +1884,7 @@ namespace libtorrent struct TORRENT_EXPORT session_stats_alert : alert { session_stats_alert(aux::stack_allocator& alloc, counters const& cnt); - TORRENT_DEFINE_ALERT_PRIO(session_stats_alert, 70); + TORRENT_DEFINE_ALERT_PRIO(session_stats_alert, 70) static const int static_category = alert::stats_notification; virtual std::string message() const; @@ -1917,7 +1917,7 @@ namespace libtorrent torrent_update_alert(aux::stack_allocator& alloc, torrent_handle h , sha1_hash const& old_hash, sha1_hash const& new_hash); - TORRENT_DEFINE_ALERT_PRIO(torrent_update_alert, 71); + TORRENT_DEFINE_ALERT_PRIO(torrent_update_alert, 71) static const int static_category = alert::status_notification; virtual std::string message() const; @@ -1942,7 +1942,7 @@ namespace libtorrent rss_item_alert(aux::stack_allocator& alloc, feed_handle h , feed_item const& item); - TORRENT_DEFINE_ALERT(rss_item_alert, 72); + TORRENT_DEFINE_ALERT(rss_item_alert, 72) static const int static_category = alert::rss_notification; virtual std::string message() const; @@ -1959,7 +1959,7 @@ namespace libtorrent // internal dht_error_alert(aux::stack_allocator& alloc, int op, error_code const& ec); - TORRENT_DEFINE_ALERT(dht_error_alert, 73); + TORRENT_DEFINE_ALERT(dht_error_alert, 73) static const int static_category = alert::error_notification | alert::dht_notification; @@ -1985,7 +1985,7 @@ namespace libtorrent dht_immutable_item_alert(aux::stack_allocator& alloc, sha1_hash const& t , entry const& i); - TORRENT_DEFINE_ALERT_PRIO(dht_immutable_item_alert, 74); + TORRENT_DEFINE_ALERT_PRIO(dht_immutable_item_alert, 74) static const int static_category = alert::error_notification | alert::dht_notification; @@ -2014,7 +2014,7 @@ namespace libtorrent , std::string const& s , entry const& i); - TORRENT_DEFINE_ALERT_PRIO(dht_mutable_item_alert, 75); + TORRENT_DEFINE_ALERT_PRIO(dht_mutable_item_alert, 75) static const int static_category = alert::error_notification | alert::dht_notification; @@ -2055,7 +2055,7 @@ namespace libtorrent , std::string s , boost::uint64_t sequence_number); - TORRENT_DEFINE_ALERT(dht_put_alert, 76); + TORRENT_DEFINE_ALERT(dht_put_alert, 76) static const int static_category = alert::dht_notification; virtual std::string message() const; @@ -2077,7 +2077,7 @@ namespace libtorrent { i2p_alert(aux::stack_allocator& alloc, error_code const& ec); - TORRENT_DEFINE_ALERT(i2p_alert, 77); + TORRENT_DEFINE_ALERT(i2p_alert, 77) static const int static_category = alert::error_notification; virtual std::string message() const; @@ -2099,7 +2099,7 @@ namespace libtorrent , ip(ep) {} - TORRENT_DEFINE_ALERT(dht_outgoing_get_peers_alert, 78); + TORRENT_DEFINE_ALERT(dht_outgoing_get_peers_alert, 78) static const int static_category = alert::dht_notification; virtual std::string message() const; @@ -2124,7 +2124,7 @@ namespace libtorrent // internal log_alert(aux::stack_allocator& alloc, char const* log); - TORRENT_DEFINE_ALERT(log_alert, 79); + TORRENT_DEFINE_ALERT(log_alert, 79) static const int static_category = alert::session_log_notification; virtual std::string message() const; @@ -2147,7 +2147,7 @@ namespace libtorrent torrent_log_alert(aux::stack_allocator& alloc, torrent_handle h , char const* log); - TORRENT_DEFINE_ALERT(torrent_log_alert, 80); + TORRENT_DEFINE_ALERT(torrent_log_alert, 80) static const int static_category = alert::torrent_log_notification; virtual std::string message() const; @@ -2170,7 +2170,7 @@ namespace libtorrent , tcp::endpoint const& i , peer_id const& pi, char const* log); - TORRENT_DEFINE_ALERT(peer_log_alert, 81); + TORRENT_DEFINE_ALERT(peer_log_alert, 81) static const int static_category = alert::peer_log_notification; virtual std::string message() const; @@ -2192,7 +2192,7 @@ namespace libtorrent , error(ec) {} - TORRENT_DEFINE_ALERT(lsd_error_alert, 82); + TORRENT_DEFINE_ALERT(lsd_error_alert, 82) static const int static_category = alert::error_notification; virtual std::string message() const; @@ -2270,7 +2270,7 @@ namespace libtorrent , routing_table(table) {} - TORRENT_DEFINE_ALERT(dht_stats_alert, 83); + TORRENT_DEFINE_ALERT(dht_stats_alert, 83) static const int static_category = alert::stats_notification; virtual std::string message() const; diff --git a/include/libtorrent/allocator.hpp b/include/libtorrent/allocator.hpp index aee5569bb..28c13916e 100644 --- a/include/libtorrent/allocator.hpp +++ b/include/libtorrent/allocator.hpp @@ -43,7 +43,7 @@ namespace libtorrent struct TORRENT_EXTRA_EXPORT page_aligned_allocator { - typedef std::size_t size_type; + typedef int size_type; typedef std::ptrdiff_t difference_type; static char* malloc(const size_type bytes); diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index 46b210de8..09ec54d2d 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" -#if (defined TORRENT_DEBUG && !TORRENT_NO_ASSERTS) \ +#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \ || defined TORRENT_ASIO_DEBUGGING \ || defined TORRENT_PROFILE_CALLS \ || TORRENT_RELEASE_ASSERTS \ @@ -47,11 +47,11 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0); #if TORRENT_USE_ASSERTS -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS extern char const* libtorrent_assert_log; #endif -#if !TORRENT_USE_SYSTEM_ASSERT +#ifndef TORRENT_USE_SYSTEM_ASSERTS #if TORRENT_USE_IOSTREAM #include @@ -59,8 +59,8 @@ extern char const* libtorrent_assert_log; TORRENT_EXPORT void assert_print(char const* fmt, ...); -TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file - , char const* function, char const* val, int kind = 0); +TORRENT_NO_RETURN 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) diff --git a/include/libtorrent/aux_/disable_warnings_pop.hpp b/include/libtorrent/aux_/disable_warnings_pop.hpp new file mode 100644 index 000000000..57f439859 --- /dev/null +++ b/include/libtorrent/aux_/disable_warnings_pop.hpp @@ -0,0 +1,40 @@ +/* + +Copyright (c) 2015, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + diff --git a/include/libtorrent/aux_/disable_warnings_push.hpp b/include/libtorrent/aux_/disable_warnings_push.hpp new file mode 100644 index 000000000..68c6b3bf8 --- /dev/null +++ b/include/libtorrent/aux_/disable_warnings_push.hpp @@ -0,0 +1,69 @@ +/* + +Copyright (c) 2015, Arvid Norberg +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wswitch-enum" +#pragma GCC diagnostic ignored "-Wcovered-switch-default" +#pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wundef" +#pragma GCC diagnostic ignored "-Wweak-vtables" +#pragma GCC diagnostic ignored "-Wmissing-noreturn" +#pragma GCC diagnostic ignored "-Wdeprecated" +#pragma GCC diagnostic ignored "-Wshadow" +#endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Weverything" +#pragma clang diagnostic ignored "-Wsign-conversion" +#pragma clang diagnostic ignored "-Wconversion" +#pragma clang diagnostic ignored "-Wswitch-enum" +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#pragma clang diagnostic ignored "-Wold-style-cast" +#pragma clang diagnostic ignored "-Wundef" +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wmissing-noreturn" +#pragma clang diagnostic ignored "-Wdeprecated" +#pragma clang diagnostic ignored "-Wcast-align" +#pragma clang diagnostic ignored "-Wweak-vtable" +#pragma clang diagnostic ignored "-Wundef" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +#ifdef _MSC_VER +#pragma warning(push, 1) +#endif + diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 2c3f0d9e8..d920c5319 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -33,12 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SESSION_IMPL_HPP_INCLUDED #define TORRENT_SESSION_IMPL_HPP_INCLUDED -#include -#include -#include -#include -#include // for va_start, va_end - #include "libtorrent/config.hpp" #include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/aux_/session_interface.hpp" @@ -48,18 +42,24 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_peer_allocator.hpp" #include "libtorrent/performance_counters.hpp" // for counters -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" + +#include +#include +#include +#include +#include // for va_start, va_end #if TORRENT_HAS_BOOST_UNORDERED #include #endif -#ifdef _MSC_VER -#pragma warning(pop) +#ifdef TORRENT_USE_OPENSSL +#include #endif +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/session.hpp" // for user_load_function_t #include "libtorrent/ip_voter.hpp" #include "libtorrent/torrent_handle.hpp" @@ -100,10 +100,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_connection.hpp" #endif -#ifdef TORRENT_USE_OPENSSL -#include -#endif - namespace libtorrent { diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index d41f6b916..c4cba067e 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -35,17 +35,12 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/peer_id.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include #include -#include "libtorrent/address.hpp" -#include "libtorrent/io_service.hpp" -#include "libtorrent/disk_buffer_holder.hpp" - -#ifndef TORRENT_DISABLE_DHT -#include "libtorrent/socket.hpp" -#endif - #ifndef TORRENT_DISABLE_LOGGING #include #endif @@ -54,6 +49,16 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/address.hpp" +#include "libtorrent/io_service.hpp" +#include "libtorrent/disk_buffer_holder.hpp" + +#ifndef TORRENT_DISABLE_DHT +#include "libtorrent/socket.hpp" +#endif + #include "libtorrent/socket.hpp" // for tcp::endpoint namespace libtorrent diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index fddab0a45..55c5e5fe1 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -33,8 +33,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED #define TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include +#include "aux_/disable_warnings_pop.hpp" + #ifdef TORRENT_VERBOSE_BANDWIDTH_LIMIT #include #endif diff --git a/include/libtorrent/bandwidth_queue_entry.hpp b/include/libtorrent/bandwidth_queue_entry.hpp index ba9d5476c..a51d7ef41 100644 --- a/include/libtorrent/bandwidth_queue_entry.hpp +++ b/include/libtorrent/bandwidth_queue_entry.hpp @@ -33,7 +33,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_BANDWIDTH_QUEUE_ENTRY_HPP_INCLUDED #define TORRENT_BANDWIDTH_QUEUE_ENTRY_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/bandwidth_limit.hpp" #include "libtorrent/bandwidth_socket.hpp" diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index 322775d18..e6410f6a9 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -30,10 +30,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/assert.hpp" #ifndef TORRENT_BDECODE_HPP diff --git a/include/libtorrent/bencode.hpp b/include/libtorrent/bencode.hpp index c46076a5e..e04b1ea1b 100644 --- a/include/libtorrent/bencode.hpp +++ b/include/libtorrent/bencode.hpp @@ -76,15 +76,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for distance -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/entry.hpp" #include "libtorrent/config.hpp" diff --git a/include/libtorrent/bitfield.hpp b/include/libtorrent/bitfield.hpp index 2610f5f4f..957d6d9bd 100644 --- a/include/libtorrent/bitfield.hpp +++ b/include/libtorrent/bitfield.hpp @@ -85,7 +85,7 @@ namespace libtorrent resize(bits); if (bits > 0) { - std::memcpy(m_buf, b, ((bits + 7) / 8)); + std::memcpy(m_buf, b, size_t((bits + 7) / 8)); clear_trailing_bits(); } } @@ -143,7 +143,7 @@ namespace libtorrent // returns the size of the bitfield in bits. int size() const { - return m_buf == NULL ? 0 : m_buf[-1]; + return m_buf == NULL ? 0 : int(m_buf[-1]); } int num_words() const @@ -156,7 +156,7 @@ namespace libtorrent // returns a pointer to the internal buffer of the bitfield. // TODO: rename to data() ? - char const* bytes() const { return (char const*)m_buf; } + char const* bytes() const { return reinterpret_cast(m_buf); } // copy operator bitfield& operator=(bitfield const& rhs) @@ -287,13 +287,15 @@ namespace libtorrent { if (old_size_words && b) m_buf[old_size_words - 1] |= htonl((0xffffffff >> b)); if (old_size_words < new_size_words) - std::memset(m_buf + old_size_words, 0xff, (new_size_words - old_size_words) * 4); + std::memset(m_buf + old_size_words, 0xff + , size_t((new_size_words - old_size_words) * 4)); clear_trailing_bits(); } else { if (old_size_words < new_size_words) - std::memset(m_buf + old_size_words, 0x00, (new_size_words - old_size_words) * 4); + std::memset(m_buf + old_size_words, 0x00 + , size_t((new_size_words - old_size_words) * 4)); } TORRENT_ASSERT(size() == bits); } @@ -329,12 +331,12 @@ namespace libtorrent // set all bits in the bitfield to 1 (set_all) or 0 (clear_all). void set_all() { - std::memset(m_buf, 0xff, num_words() * 4); + std::memset(m_buf, 0xff, size_t(num_words() * 4)); clear_trailing_bits(); } void clear_all() { - std::memset(m_buf, 0x00, num_words() * 4); + std::memset(m_buf, 0x00, size_t(num_words() * 4)); } // make the bitfield empty, of zero size. diff --git a/include/libtorrent/block_cache.hpp b/include/libtorrent/block_cache.hpp index fb7df7321..78160edf4 100644 --- a/include/libtorrent/block_cache.hpp +++ b/include/libtorrent/block_cache.hpp @@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_BLOCK_CACHE #define TORRENT_BLOCK_CACHE +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -40,6 +42,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/time.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/io_service_fwd.hpp" diff --git a/include/libtorrent/bloom_filter.hpp b/include/libtorrent/bloom_filter.hpp index b93741ec1..b471e717d 100644 --- a/include/libtorrent/bloom_filter.hpp +++ b/include/libtorrent/bloom_filter.hpp @@ -33,12 +33,16 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_BLOOM_FILTER_HPP_INCLUDED #define TORRENT_BLOOM_FILTER_HPP_INCLUDED -#include #include "libtorrent/peer_id.hpp" // for sha1_hash #include "libtorrent/config.hpp" // for sha1_hash +#include "aux_/disable_warnings_push.hpp" + +#include #include // for log() +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { TORRENT_EXTRA_EXPORT void set_bits(boost::uint8_t const* b, boost::uint8_t* bits, int len); diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 56a829a8c..934599988 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -41,9 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include @@ -51,9 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/buffer.hpp" #include "libtorrent/peer_connection.hpp" diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 1c60df243..c31c1126b 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -389,6 +389,12 @@ int snprintf(char* buf, int len, char const* fmt, ...) #include #endif +#if defined __cplusplus && __cplusplus >= 199711L +#define TORRENT_NO_RETURN [[noreturn]] +#else +#define TORRENT_NO_RETURN +#endif + #ifndef TORRENT_ICONV_ARG #define TORRENT_ICONV_ARG (char**) #endif @@ -442,6 +448,14 @@ int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_HAS_SEM_RELTIMEDWAIT 0 #endif +#ifndef TORRENT_USE_MEMALIGN +#define TORRENT_USE_MEMALIGN 0 +#endif + +#ifndef TORRENT_USE_POSIX_MEMALIGN +#define TORRENT_USE_POSIX_MEMALIGN 0 +#endif + #ifndef TORRENT_USE_LOCALE #define TORRENT_USE_LOCALE 0 #endif @@ -525,7 +539,7 @@ int snprintf(char* buf, int len, char const* fmt, ...) #endif #ifndef TORRENT_THREADSAFE_STATIC -#if __cplusplus < 199711L || _MSC_VER <= 1800 +#if __cplusplus < 199711L || (defined _MSC_VER && _MSC_VER <= 1800) #define TORRENT_THREADSAFE_STATIC 0 #else #define TORRENT_THREADSAFE_STATIC 1 @@ -592,6 +606,7 @@ int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_FUNCTION __FUNCTION__ #endif + // debug builds have asserts enabled by default, release // builds have asserts if they are explicitly enabled by // the release_asserts macro. @@ -603,7 +618,7 @@ int snprintf(char* buf, int len, char const* fmt, ...) #endif #endif // TORRENT_USE_ASSERTS -#if defined TORRENT_DEBUG && TORRENT_USE_ASSERTS \ +#if defined TORRENT_DEBUG && defined TORRENT_USE_ASSERTS \ && !defined TORRENT_DISABLE_INVARIANT_CHECKS #define TORRENT_USE_INVARIANT_CHECKS 1 #else diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index c5079d577..fa91300ea 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -43,20 +43,16 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/allocator.hpp" #include "libtorrent/file.hpp" // for combine_path etc. +#include "aux_/disable_warnings_push.hpp" + #include #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" // OVERVIEW // diff --git a/include/libtorrent/disk_buffer_pool.hpp b/include/libtorrent/disk_buffer_pool.hpp index 093bba5eb..7c4c8ae23 100644 --- a/include/libtorrent/disk_buffer_pool.hpp +++ b/include/libtorrent/disk_buffer_pool.hpp @@ -33,25 +33,30 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISK_BUFFER_POOL_HPP #define TORRENT_DISK_BUFFER_POOL_HPP -#include - #include "libtorrent/config.hpp" -#include "libtorrent/thread.hpp" -#include "libtorrent/io_service_fwd.hpp" -#include "libtorrent/file.hpp" // for iovec_t + +#include "aux_/disable_warnings_push.hpp" + #include #include #include - -#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS -#include -#endif +#include #ifndef TORRENT_DISABLE_POOL_ALLOCATOR #include "libtorrent/allocator.hpp" // for page_aligned_allocator #include #endif +#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS +#include +#endif + +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/thread.hpp" +#include "libtorrent/io_service_fwd.hpp" +#include "libtorrent/file.hpp" // for iovec_t + namespace libtorrent { namespace aux { struct session_settings; } diff --git a/include/libtorrent/disk_io_job.hpp b/include/libtorrent/disk_io_job.hpp index 15675a425..c7759f4fb 100644 --- a/include/libtorrent/disk_io_job.hpp +++ b/include/libtorrent/disk_io_job.hpp @@ -33,15 +33,20 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISK_IO_JOB_HPP #define TORRENT_DISK_IO_JOB_HPP -#include #include "libtorrent/time.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/tailqueue.hpp" #include "libtorrent/peer_id.hpp" + +#include "aux_/disable_warnings_push.hpp" + +#include #include #include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { class entry; diff --git a/include/libtorrent/disk_job_pool.hpp b/include/libtorrent/disk_job_pool.hpp index 65fa85aab..9e8329cea 100644 --- a/include/libtorrent/disk_job_pool.hpp +++ b/include/libtorrent/disk_job_pool.hpp @@ -35,8 +35,13 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/thread.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { struct disk_io_job; diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 3386abdf5..ebfafb943 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -303,7 +303,7 @@ namespace libtorrent #ifndef BOOST_NO_EXCEPTIONS // internal - inline void throw_type_error() + TORRENT_NO_RETURN inline void throw_type_error() { throw libtorrent_exception(error_code(errors::invalid_entry_type , get_libtorrent_category())); diff --git a/include/libtorrent/enum_net.hpp b/include/libtorrent/enum_net.hpp index 74327a0af..79e580933 100644 --- a/include/libtorrent/enum_net.hpp +++ b/include/libtorrent/enum_net.hpp @@ -34,16 +34,22 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_ENUM_NET_HPP_INCLUDED #include "libtorrent/config.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include #include -#include "libtorrent/io_service_fwd.hpp" -#include "libtorrent/address.hpp" -#include "libtorrent/error_code.hpp" #if TORRENT_USE_IFCONF || TORRENT_USE_NETLINK || TORRENT_USE_SYSCTL #include // for SO_BINDTODEVICE #endif +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/io_service_fwd.hpp" +#include "libtorrent/address.hpp" +#include "libtorrent/error_code.hpp" + namespace libtorrent { struct socket_type; diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index 12be2f4fa..40bcc5481 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -35,6 +35,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include "libtorrent/config.hpp" +#include "libtorrent/string_util.hpp" // for allocate_string_copy +#include // free + +#include "libtorrent/aux_/disable_warnings_push.hpp" #if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN // asio assumes that the windows error codes are defined already @@ -47,8 +51,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -#include "libtorrent/string_util.hpp" // for allocate_string_copy -#include // free +#include "libtorrent/aux_/disable_warnings_pop.hpp" #ifndef BOOST_SYSTEM_NOEXCEPT #define BOOST_SYSTEM_NOEXCEPT throw() @@ -59,8 +62,10 @@ namespace libtorrent namespace errors { - // libtorrent uses boost.system's ``error_code`` class to represent errors. libtorrent has - // its own error category get_libtorrent_category() whith the error codes defined by error_code_enum. + // libtorrent uses boost.system's ``error_code`` class to represent + // errors. libtorrent has its own error category + // get_libtorrent_category() whith the error codes defined by + // error_code_enum. enum error_code_enum { // Not an error @@ -535,8 +540,8 @@ namespace libtorrent struct TORRENT_EXPORT libtorrent_exception: std::exception { libtorrent_exception(error_code const& s): m_error(s), m_msg(0) {} - virtual const char* what() const throw(); - virtual ~libtorrent_exception() throw(); + virtual const char* what() const BOOST_SYSTEM_NOEXCEPT; + virtual ~libtorrent_exception() BOOST_SYSTEM_NOEXCEPT; error_code error() const { return m_error; } private: error_code m_error; @@ -619,6 +624,9 @@ namespace boost { namespace system { #endif // BOOST_VERSION +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #endif diff --git a/include/libtorrent/export.hpp b/include/libtorrent/export.hpp index 6a31c13fb..1ace0c7f2 100644 --- a/include/libtorrent/export.hpp +++ b/include/libtorrent/export.hpp @@ -69,7 +69,7 @@ POSSIBILITY OF SUCH DAMAGE. // when this is specified, export a bunch of extra // symbols, mostly for the unit tests to reach -#if TORRENT_EXPORT_EXTRA +#if defined TORRENT_EXPORT_EXTRA # if defined TORRENT_BUILDING_SHARED # define TORRENT_EXTRA_EXPORT BOOST_SYMBOL_EXPORT # elif defined TORRENT_LINKING_SHARED diff --git a/include/libtorrent/extensions.hpp b/include/libtorrent/extensions.hpp index 089e56e8e..c3e16b865 100644 --- a/include/libtorrent/extensions.hpp +++ b/include/libtorrent/extensions.hpp @@ -165,15 +165,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include #include "libtorrent/config.hpp" diff --git a/include/libtorrent/extensions/lt_trackers.hpp b/include/libtorrent/extensions/lt_trackers.hpp index 8587ee057..05ccb276b 100644 --- a/include/libtorrent/extensions/lt_trackers.hpp +++ b/include/libtorrent/extensions/lt_trackers.hpp @@ -35,16 +35,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include "libtorrent/config.hpp" -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/extensions/metadata_transfer.hpp b/include/libtorrent/extensions/metadata_transfer.hpp index 2d6f44933..7a7dc9409 100644 --- a/include/libtorrent/extensions/metadata_transfer.hpp +++ b/include/libtorrent/extensions/metadata_transfer.hpp @@ -35,16 +35,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - -#include #include "libtorrent/config.hpp" -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_push.hpp" + +#include + +#include "aux_/disable_warnings_pop.hpp" #ifndef TORRENT_NO_DEPRECATE diff --git a/include/libtorrent/extensions/smart_ban.hpp b/include/libtorrent/extensions/smart_ban.hpp index ba0ccb213..e249ba1d0 100644 --- a/include/libtorrent/extensions/smart_ban.hpp +++ b/include/libtorrent/extensions/smart_ban.hpp @@ -35,16 +35,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include "libtorrent/config.hpp" -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/extensions/ut_metadata.hpp b/include/libtorrent/extensions/ut_metadata.hpp index 4daab9b6a..c367ffe88 100644 --- a/include/libtorrent/extensions/ut_metadata.hpp +++ b/include/libtorrent/extensions/ut_metadata.hpp @@ -35,16 +35,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include "libtorrent/config.hpp" -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/extensions/ut_pex.hpp b/include/libtorrent/extensions/ut_pex.hpp index fc91ef7f2..55c127b44 100644 --- a/include/libtorrent/extensions/ut_pex.hpp +++ b/include/libtorrent/extensions/ut_pex.hpp @@ -35,16 +35,12 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include "libtorrent/config.hpp" -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index c79340bf6..5153a193f 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -36,21 +36,13 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "libtorrent/config.hpp" + +#include "aux_/disable_warnings_push.hpp" #include #include - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#include "libtorrent/config.hpp" -#include "libtorrent/error_code.hpp" -#include "libtorrent/assert.hpp" -#include "libtorrent/time.hpp" +#include #ifdef TORRENT_WINDOWS // windows part @@ -82,7 +74,11 @@ POSSIBILITY OF SUCH DAMAGE. #endif -#include +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/error_code.hpp" +#include "libtorrent/assert.hpp" +#include "libtorrent/time.hpp" namespace libtorrent { @@ -206,7 +202,7 @@ namespace libtorrent struct file; -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS struct file_handle { file_handle(); @@ -338,7 +334,7 @@ namespace libtorrent boost::uint32_t file_id() const { return m_file_id; } #endif -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS void print_info(FILE* out) const; #endif @@ -365,7 +361,7 @@ namespace libtorrent static bool has_manage_volume_privs; #endif -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS std::string m_file_path; #endif }; diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index fe79c24de..ed8c52c45 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -33,12 +33,17 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_FILE_STORAGE_HPP_INCLUDED #define TORRENT_FILE_STORAGE_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include #include #include + #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/assert.hpp" #include "libtorrent/peer_request.hpp" #include "libtorrent/peer_id.hpp" diff --git a/include/libtorrent/fingerprint.hpp b/include/libtorrent/fingerprint.hpp index 880a1289b..a46394b5d 100644 --- a/include/libtorrent/fingerprint.hpp +++ b/include/libtorrent/fingerprint.hpp @@ -115,8 +115,8 @@ namespace libtorrent char version_to_char(int v) const { - if (v >= 0 && v < 10) return '0' + v; - else if (v >= 10) return 'A' + (v - 10); + if (v >= 0 && v < 10) return char('0' + v); + else if (v >= 10) return char('A' + (v - 10)); TORRENT_ASSERT(false); return '0'; } diff --git a/include/libtorrent/heterogeneous_queue.hpp b/include/libtorrent/heterogeneous_queue.hpp index 5fa4341ab..9dc561512 100644 --- a/include/libtorrent/heterogeneous_queue.hpp +++ b/include/libtorrent/heterogeneous_queue.hpp @@ -69,7 +69,7 @@ namespace libtorrent { uintptr_t* ptr = m_storage + m_size; // length prefix - header_t* hdr = (header_t*)ptr; + header_t* hdr = reinterpret_cast(ptr); hdr->len = object_size; hdr->move = &move; ptr += header_size; @@ -91,10 +91,10 @@ namespace libtorrent { uintptr_t const* const end = m_storage + m_size; while (ptr < end) { - header_t* hdr = (header_t*)ptr; + header_t* hdr = reinterpret_cast(ptr); ptr += header_size; TORRENT_ASSERT(ptr + hdr->len <= end); - out.push_back((T*)ptr); + out.push_back(reinterpret_cast(ptr)); ptr += hdr->len; } } @@ -116,10 +116,10 @@ namespace libtorrent { uintptr_t const* const end = m_storage + m_size; while (ptr < end) { - header_t* hdr = (header_t*)ptr; + header_t* hdr = reinterpret_cast(ptr); ptr += header_size; TORRENT_ASSERT(ptr + hdr->len <= end); - T* a = (T*)ptr; + T* a = reinterpret_cast(ptr); a->~T(); ptr += hdr->len; } @@ -133,10 +133,10 @@ namespace libtorrent { TORRENT_ASSERT(m_size > 1); uintptr_t* ptr = m_storage; - header_t* hdr = (header_t*)ptr; + header_t* hdr = reinterpret_cast(ptr); ptr += header_size; TORRENT_ASSERT(hdr->len <= m_size); - return (T*)ptr; + return reinterpret_cast(ptr); } ~heterogeneous_queue() @@ -176,8 +176,8 @@ namespace libtorrent { uintptr_t const* const end = m_storage + m_size; while (src < end) { - header_t* src_hdr = (header_t*)src; - header_t* dst_hdr = (header_t*)dst; + header_t* src_hdr = reinterpret_cast(src); + header_t* dst_hdr = reinterpret_cast(dst); *dst_hdr = *src_hdr; src += header_size; dst += header_size; @@ -196,7 +196,7 @@ namespace libtorrent { template static void move(uintptr_t* dst, uintptr_t* src) { - U* rhs = (U*)src; + U* rhs = reinterpret_cast(src); #if __cplusplus >= 201103L new (dst) U(std::move(*rhs)); #else diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index 5f5d80ca3..e43c75cb7 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_HTTP_CONNECTION #define TORRENT_HTTP_CONNECTION +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -43,6 +45,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#ifdef TORRENT_USE_OPENSSL +#include +#endif + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/socket.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/http_parser.hpp" @@ -53,10 +61,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/i2p_stream.hpp" -#ifdef TORRENT_USE_OPENSSL -#include -#endif - namespace libtorrent { diff --git a/include/libtorrent/http_parser.hpp b/include/libtorrent/http_parser.hpp index 93cf5a50d..bbf5dbe7e 100644 --- a/include/libtorrent/http_parser.hpp +++ b/include/libtorrent/http_parser.hpp @@ -38,16 +38,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" #include "libtorrent/buffer.hpp" diff --git a/include/libtorrent/http_seed_connection.hpp b/include/libtorrent/http_seed_connection.hpp index 73cd65851..db3c2eecb 100644 --- a/include/libtorrent/http_seed_connection.hpp +++ b/include/libtorrent/http_seed_connection.hpp @@ -40,9 +40,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include @@ -51,9 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" #include "libtorrent/web_connection_base.hpp" diff --git a/include/libtorrent/http_stream.hpp b/include/libtorrent/http_stream.hpp index d7cca6f25..cf98671fc 100644 --- a/include/libtorrent/http_stream.hpp +++ b/include/libtorrent/http_stream.hpp @@ -33,12 +33,17 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_HTTP_STREAM_HPP_INCLUDED #define TORRENT_HTTP_STREAM_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include -#include "libtorrent/proxy_base.hpp" -#include "libtorrent/string_util.hpp" #include #include +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/proxy_base.hpp" +#include "libtorrent/string_util.hpp" + namespace libtorrent { class http_stream : public proxy_base diff --git a/include/libtorrent/http_tracker_connection.hpp b/include/libtorrent/http_tracker_connection.hpp index d23bf085f..bdccbc02e 100644 --- a/include/libtorrent/http_tracker_connection.hpp +++ b/include/libtorrent/http_tracker_connection.hpp @@ -36,15 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" #include "libtorrent/lazy_entry.hpp" diff --git a/include/libtorrent/i2p_stream.hpp b/include/libtorrent/i2p_stream.hpp index c9ee27b81..df4450b3a 100644 --- a/include/libtorrent/i2p_stream.hpp +++ b/include/libtorrent/i2p_stream.hpp @@ -37,6 +37,8 @@ POSSIBILITY OF SUCH DAMAGE. #if TORRENT_USE_I2P +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -44,6 +46,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/proxy_base.hpp" #include "libtorrent/session_settings.hpp" #include "libtorrent/string_util.hpp" diff --git a/include/libtorrent/identify_client.hpp b/include/libtorrent/identify_client.hpp index ed8492b50..150e72d7a 100644 --- a/include/libtorrent/identify_client.hpp +++ b/include/libtorrent/identify_client.hpp @@ -33,15 +33,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED #define TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/fingerprint.hpp" diff --git a/include/libtorrent/io.hpp b/include/libtorrent/io.hpp index 6e0c054fb..d1e15b537 100644 --- a/include/libtorrent/io.hpp +++ b/include/libtorrent/io.hpp @@ -51,7 +51,7 @@ namespace libtorrent inline T read_impl(InIt& start, type) { T ret = 0; - for (int i = 0; i < (int)sizeof(T); ++i) + for (int i = 0; i < int(sizeof(T)); ++i) { ret <<= 8; ret |= static_cast(*start); @@ -75,7 +75,7 @@ namespace libtorrent template inline void write_impl(T val, OutIt& start) { - for (int i = (int)sizeof(T)-1; i >= 0; --i) + for (int i = int(sizeof(T))-1; i >= 0; --i) { *start = static_cast((val >> (i * 8)) & 0xff); ++start; @@ -151,7 +151,7 @@ namespace libtorrent inline int write_string(std::string const& str, char*& start) { - std::memcpy((void*)start, str.c_str(), str.size()); + std::memcpy(reinterpret_cast(start), str.c_str(), str.size()); start += str.size(); return str.size(); } diff --git a/include/libtorrent/io_service.hpp b/include/libtorrent/io_service.hpp index 91ebdd5c0..2c4fa8b28 100644 --- a/include/libtorrent/io_service.hpp +++ b/include/libtorrent/io_service.hpp @@ -37,9 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #define Protocol Protocol_ #endif -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include @@ -54,9 +52,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #ifdef __OBJC__ #undef Protocol diff --git a/include/libtorrent/io_service_fwd.hpp b/include/libtorrent/io_service_fwd.hpp index e083ef663..f9326801a 100644 --- a/include/libtorrent/io_service_fwd.hpp +++ b/include/libtorrent/io_service_fwd.hpp @@ -37,15 +37,11 @@ POSSIBILITY OF SUCH DAMAGE. #define Protocol Protocol_ #endif -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #ifdef __OBJC__ #undef Protocol diff --git a/include/libtorrent/ip_filter.hpp b/include/libtorrent/ip_filter.hpp index 23db5c500..6602e6c47 100644 --- a/include/libtorrent/ip_filter.hpp +++ b/include/libtorrent/ip_filter.hpp @@ -36,19 +36,14 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" #include "libtorrent/address.hpp" diff --git a/include/libtorrent/kademlia/routing_table.hpp b/include/libtorrent/kademlia/routing_table.hpp index 0deb676ac..f320dfe0b 100644 --- a/include/libtorrent/kademlia/routing_table.hpp +++ b/include/libtorrent/kademlia/routing_table.hpp @@ -33,23 +33,26 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef ROUTING_TABLE_HPP #define ROUTING_TABLE_HPP -#include -#include +#include "aux_/disable_warnings_push.hpp" +#include +#include + +#include #include #include #include #include -#include +#include + +#include "aux_/disable_warnings_pop.hpp" #include - #include #include #include #include #include -#include namespace libtorrent { diff --git a/include/libtorrent/kademlia/rpc_manager.hpp b/include/libtorrent/kademlia/rpc_manager.hpp index 07e1a0539..494bc59d0 100644 --- a/include/libtorrent/kademlia/rpc_manager.hpp +++ b/include/libtorrent/kademlia/rpc_manager.hpp @@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef RPC_MANAGER_HPP #define RPC_MANAGER_HPP +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -46,6 +48,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include "aux_/disable_warnings_pop.hpp" + #include #include #include diff --git a/include/libtorrent/parse_url.hpp b/include/libtorrent/parse_url.hpp index f4a6ac8b7..bdca5a962 100644 --- a/include/libtorrent/parse_url.hpp +++ b/include/libtorrent/parse_url.hpp @@ -33,15 +33,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PARSE_URL_HPP_INCLUDED #define TORRENT_PARSE_URL_HPP_INCLUDED -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include #include "libtorrent/config.hpp" diff --git a/include/libtorrent/part_file.hpp b/include/libtorrent/part_file.hpp index 298d28bf2..e6a0f2f93 100644 --- a/include/libtorrent/part_file.hpp +++ b/include/libtorrent/part_file.hpp @@ -30,10 +30,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/config.hpp" #include "libtorrent/file.hpp" #include "libtorrent/error_code.hpp" diff --git a/include/libtorrent/peer_class.hpp b/include/libtorrent/peer_class.hpp index 0d376b2b6..648587c56 100644 --- a/include/libtorrent/peer_class.hpp +++ b/include/libtorrent/peer_class.hpp @@ -36,11 +36,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bandwidth_limit.hpp" #include "libtorrent/assert.hpp" +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { typedef boost::uint8_t peer_class_t; diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index 7f6d3dd96..5d51159ac 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -42,9 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #endif -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include @@ -55,9 +53,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/buffer.hpp" #include "libtorrent/peer_id.hpp" diff --git a/include/libtorrent/performance_counters.hpp b/include/libtorrent/performance_counters.hpp index cd21c2ea3..d1b36fb54 100644 --- a/include/libtorrent/performance_counters.hpp +++ b/include/libtorrent/performance_counters.hpp @@ -33,8 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PERFORMANCE_COUNTERS_HPP_INCLUDED #define TORRENT_PERFORMANCE_COUNTERS_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/config.hpp" namespace libtorrent diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index 2b5830469..774d03b08 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -32,34 +32,25 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_PIECE_PICKER_HPP_INCLUDED #define TORRENT_PIECE_PICKER_HPP_INCLUDED -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#include "libtorrent/peer_id.hpp" -#include "libtorrent/config.hpp" -#include "libtorrent/assert.hpp" -#include "libtorrent/time.hpp" - // this is really only useful for debugging unit tests //#define TORRENT_PICKER_LOG // heavy weight reference counting invariant checks //#define TORRENT_DEBUG_REFCOUNTS +#include "libtorrent/config.hpp" + +#include "aux_/disable_warnings_push.hpp" + +#include +#include +#include +#include + +#include +#include +#include + #ifdef TORRENT_DEBUG_REFCOUNTS #include #endif @@ -68,6 +59,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/peer_id.hpp" +#include "libtorrent/assert.hpp" +#include "libtorrent/time.hpp" + namespace libtorrent { @@ -499,10 +496,10 @@ namespace libtorrent { piece_pos() {} piece_pos(int peer_count_, int index_) - : peer_count(peer_count_) + : peer_count(unsigned(peer_count_)) , download_state(piece_pos::piece_open) , piece_priority(4) - , index(index_) + , index(unsigned(index_)) { TORRENT_ASSERT(peer_count_ >= 0); TORRENT_ASSERT(index_ >= 0); @@ -582,7 +579,7 @@ namespace libtorrent // the number of peers that has this piece // (availability) -#if TORRENT_OPTIMIZE_MEMORY_USAGE +#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE boost::uint32_t peer_count : 9; #else boost::uint32_t peer_count : 16; @@ -614,7 +611,7 @@ namespace libtorrent boost::uint32_t piece_priority : 3; // index in to the piece_info vector -#if TORRENT_OPTIMIZE_MEMORY_USAGE +#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE boost::uint32_t index : 17; #else boost::uint32_t index; @@ -630,7 +627,7 @@ namespace libtorrent // index is set to this to indicate that we have the // piece. There is no entry for the piece in the // buckets if this is the case. -#if TORRENT_OPTIMIZE_MEMORY_USAGE +#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE we_have_index = 0x3ffff, #else we_have_index = 0xffffffff, @@ -638,7 +635,7 @@ namespace libtorrent // the priority value that means the piece is filtered filter_priority = 0, // the max number the peer count can hold -#if TORRENT_OPTIMIZE_MEMORY_USAGE +#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE max_peer_count = 0x1ff #else max_peer_count = 0xffff @@ -710,7 +707,7 @@ namespace libtorrent }; #ifndef TORRENT_DEBUG_REFCOUNTS -#if TORRENT_OPTIMIZE_MEMORY_USAGE +#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 4); #else BOOST_STATIC_ASSERT(sizeof(piece_pos) == sizeof(char) * 8); @@ -843,7 +840,7 @@ namespace libtorrent mutable bool m_dirty; public: -#if TORRENT_OPTIMIZE_MEMORY_USAGE +#ifdef TORRENT_OPTIMIZE_MEMORY_USAGE enum { max_pieces = piece_pos::we_have_index - 1 }; #else // still limited by piece_block diff --git a/include/libtorrent/resolve_links.hpp b/include/libtorrent/resolve_links.hpp index da47361f6..c3dd7e370 100644 --- a/include/libtorrent/resolve_links.hpp +++ b/include/libtorrent/resolve_links.hpp @@ -33,10 +33,15 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_RESOLVE_LINKS_HPP #define TORRENT_RESOLVE_LINKS_HPP +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/export.hpp" namespace libtorrent diff --git a/include/libtorrent/resolver.hpp b/include/libtorrent/resolver.hpp index 873df0a0d..2c998dbe1 100644 --- a/include/libtorrent/resolver.hpp +++ b/include/libtorrent/resolver.hpp @@ -33,10 +33,15 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_RESOLVER_HPP_INCLUDE #define TORRENT_RESOLVER_HPP_INCLUDE +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/error_code.hpp" #include "libtorrent/io_service.hpp" #include "libtorrent/resolver_interface.hpp" diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index b8f119fb2..513835dc5 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -36,16 +36,15 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include - #ifdef _MSC_VER -#pragma warning(pop) +# include #endif +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/config.hpp" #include "libtorrent/torrent_handle.hpp" #include "libtorrent/entry.hpp" @@ -62,10 +61,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/storage.hpp" #include "libtorrent/session_settings.hpp" -#ifdef _MSC_VER -# include -#endif - #ifndef TORRENT_NO_DEPRECATE #include "libtorrent/rss.hpp" #endif diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index 016435817..35cfeb8f9 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -305,7 +305,7 @@ namespace libtorrent // return a copy of the 20 bytes representing the sha1-hash as a std::string. // It's still a binary string with 20 binary characters. std::string to_string() const - { return std::string((char const*)&m_number[0], size); } + { return std::string(reinterpret_cast(&m_number[0]), size); } private: @@ -327,7 +327,7 @@ namespace libtorrent inline std::ostream& operator<<(std::ostream& os, sha1_hash const& peer) { char out[41]; - to_hex((char const*)&peer[0], sha1_hash::size, out); + to_hex(reinterpret_cast(&peer[0]), sha1_hash::size, out); return os << out; } @@ -336,7 +336,7 @@ namespace libtorrent { char hex[40]; is.read(hex, 40); - if (!from_hex(hex, 40, (char*)&peer[0])) + if (!from_hex(hex, 40, reinterpret_cast(&peer[0]))) is.setstate(std::ios_base::failbit); return is; } diff --git a/include/libtorrent/socket.hpp b/include/libtorrent/socket.hpp index f063d3b83..e1e7a3193 100644 --- a/include/libtorrent/socket.hpp +++ b/include/libtorrent/socket.hpp @@ -33,9 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SOCKET_HPP_INCLUDED #define TORRENT_SOCKET_HPP_INCLUDED -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" // if building as Objective C++, asio's template // parameters Protocol has to be renamed to avoid @@ -68,9 +66,7 @@ POSSIBILITY OF SUCH DAMAGE. #undef Protocol #endif -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" namespace libtorrent { diff --git a/include/libtorrent/socks5_stream.hpp b/include/libtorrent/socks5_stream.hpp index 9ababb88f..0d051344f 100644 --- a/include/libtorrent/socks5_stream.hpp +++ b/include/libtorrent/socks5_stream.hpp @@ -33,9 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_SOCKS5_STREAM_HPP_INCLUDED #define TORRENT_SOCKS5_STREAM_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/proxy_base.hpp" #include "libtorrent/assert.hpp" #if defined TORRENT_ASIO_DEBUGGING diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 138fd4653..5af1407ee 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -33,13 +33,10 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_STORAGE_HPP_INCLUDE #define TORRENT_STORAGE_HPP_INCLUDE +#include "aux_/disable_warnings_push.hpp" + #include #include - -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include #include @@ -49,10 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/piece_picker.hpp" #include "libtorrent/peer_request.hpp" diff --git a/include/libtorrent/thread.hpp b/include/libtorrent/thread.hpp index 02f11178a..d5927afaa 100644 --- a/include/libtorrent/thread.hpp +++ b/include/libtorrent/thread.hpp @@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/assert.hpp" #include "libtorrent/time.hpp" -#include +#include "aux_/disable_warnings_push.hpp" #if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN // asio assumes that the windows error codes are defined already @@ -55,6 +55,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { typedef boost::asio::detail::thread thread; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 7e0a0cb38..0913ec7c8 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -39,9 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include @@ -50,9 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/torrent_handle.hpp" #include "libtorrent/entry.hpp" diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 89db5a4aa..7700d844e 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -33,22 +33,18 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_TORRENT_HANDLE_HPP_INCLUDED #define TORRENT_TORRENT_HANDLE_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include #include #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/piece_picker.hpp" @@ -1223,7 +1219,7 @@ namespace libtorrent boost::uint32_t id() const { - uintptr_t ret = (uintptr_t)m_torrent.lock().get(); + uintptr_t ret = reinterpret_cast(m_torrent.lock().get()); // a torrent object is about 1024 bytes, so // it's safe to shift 11 bits return boost::uint32_t(ret >> 11); @@ -1335,6 +1331,7 @@ namespace libtorrent // ``torrent_handle::query_torrent_file``. boost::weak_ptr torrent_file; + // TODO: 3 don't use boost.date-time types here. use chrono types // the time until the torrent will announce itself to the tracker. boost::posix_time::time_duration next_announce; diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index b3d96ce9f..55777fc71 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -36,16 +36,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" #include "libtorrent/entry.hpp" diff --git a/include/libtorrent/tracker_manager.hpp b/include/libtorrent/tracker_manager.hpp index 3f164f24c..7af8d4f33 100644 --- a/include/libtorrent/tracker_manager.hpp +++ b/include/libtorrent/tracker_manager.hpp @@ -39,9 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include @@ -50,10 +48,12 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) +#ifdef TORRENT_USE_OPENSSL +#include #endif +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/config.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/address.hpp" @@ -62,9 +62,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/deadline_timer.hpp" #include "libtorrent/union_endpoint.hpp" #include "libtorrent/udp_socket.hpp" // for udp_socket_observer -#ifdef TORRENT_USE_OPENSSL -#include -#endif namespace libtorrent { diff --git a/include/libtorrent/udp_tracker_connection.hpp b/include/libtorrent/udp_tracker_connection.hpp index 2a37b0a2a..d984cd0e5 100644 --- a/include/libtorrent/udp_tracker_connection.hpp +++ b/include/libtorrent/udp_tracker_connection.hpp @@ -33,21 +33,17 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_UDP_TRACKER_CONNECTION_HPP_INCLUDED #define TORRENT_UDP_TRACKER_CONNECTION_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/udp_socket.hpp" #include "libtorrent/entry.hpp" diff --git a/include/libtorrent/web_connection_base.hpp b/include/libtorrent/web_connection_base.hpp index 8dfd58e82..4b237aad3 100644 --- a/include/libtorrent/web_connection_base.hpp +++ b/include/libtorrent/web_connection_base.hpp @@ -33,18 +33,16 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef WEB_CONNECTION_BASE_HPP_INCLUDED #define WEB_CONNECTION_BASE_HPP_INCLUDED +#include "libtorrent/debug.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include #include -#include "libtorrent/debug.hpp" - -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include #include @@ -52,9 +50,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/buffer.hpp" #include "libtorrent/peer_connection.hpp" diff --git a/include/libtorrent/web_peer_connection.hpp b/include/libtorrent/web_peer_connection.hpp index d463b42cf..2089a9076 100644 --- a/include/libtorrent/web_peer_connection.hpp +++ b/include/libtorrent/web_peer_connection.hpp @@ -33,16 +33,14 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_WEB_PEER_CONNECTION_HPP_INCLUDED #define TORRENT_WEB_PEER_CONNECTION_HPP_INCLUDED +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include #include @@ -50,9 +48,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/config.hpp" #include "libtorrent/web_connection_base.hpp" diff --git a/include/libtorrent/xml_parse.hpp b/include/libtorrent/xml_parse.hpp index db2e72af8..49d921e5c 100644 --- a/include/libtorrent/xml_parse.hpp +++ b/include/libtorrent/xml_parse.hpp @@ -33,14 +33,18 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_XML_PARSE_HPP #define TORRENT_XML_PARSE_HPP +#include "aux_/disable_warnings_push.hpp" + #include #include +#include + +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" -#include - namespace libtorrent { enum diff --git a/src/allocator.cpp b/src/allocator.cpp index 9f819e7f9..cbd20225f 100644 --- a/src/allocator.cpp +++ b/src/allocator.cpp @@ -87,7 +87,7 @@ namespace libtorrent #elif defined TORRENT_BEOS s = B_PAGE_SIZE; #else - s = sysconf(_SC_PAGESIZE); + s = int(sysconf(_SC_PAGESIZE)); #endif // assume the page size is 4 kiB if we // fail to query it @@ -112,18 +112,19 @@ namespace libtorrent char* ret; #if TORRENT_USE_POSIX_MEMALIGN - if (posix_memalign((void**)&ret, page_size(), bytes) != 0) ret = NULL; + if (posix_memalign(reinterpret_cast(&ret), page_size(), bytes) + != 0) ret = NULL; #elif TORRENT_USE_MEMALIGN - ret = (char*)memalign(page_size(), bytes); + ret = static_cast(memalign(page_size(), bytes)); #elif defined TORRENT_WINDOWS - ret = (char*)_aligned_malloc(bytes, page_size()); + ret = static_cast(_aligned_malloc(bytes, page_size())); #elif defined TORRENT_BEOS area_id id = create_area("", &ret, B_ANY_ADDRESS , (bytes + page_size() - 1) & (page_size()-1), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); if (id < B_OK) return NULL; - ret = (char*)ret; + ret = static_cast(ret); #else - ret = (char*)valloc(bytes); + ret = static_cast(valloc(size_t(bytes))); #endif if (ret == NULL) return NULL; diff --git a/src/asio.cpp b/src/asio.cpp index fc6137637..a639f1a3e 100644 --- a/src/asio.cpp +++ b/src/asio.cpp @@ -18,9 +18,13 @@ #define BOOST_ASIO_DECL BOOST_SYMBOL_EXPORT #endif +#include "aux_/disable_warnings_push.hpp" + #if BOOST_VERSION >= 104500 #include #elif BOOST_VERSION >= 104400 #include #endif +#include "aux_/disable_warnings_pop.hpp" + diff --git a/src/assert.cpp b/src/assert.cpp index e0bac2170..6d5b5bb21 100644 --- a/src/assert.cpp +++ b/src/assert.cpp @@ -31,12 +31,13 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/config.hpp" +#include "libtorrent/assert.hpp" -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS #include #endif -#if (defined TORRENT_DEBUG && !TORRENT_NO_ASSERTS) \ +#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \ || defined TORRENT_ASIO_DEBUGGING \ || defined TORRENT_PROFILE_CALLS \ || TORRENT_RELEASE_ASSERTS \ @@ -214,7 +215,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth) #if TORRENT_USE_ASSERTS || defined TORRENT_ASIO_DEBUGGING -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS char const* libtorrent_assert_log = "asserts.log"; // the number of asserts we've printed to the log boost::atomic assert_counter(0); @@ -222,7 +223,7 @@ boost::atomic assert_counter(0); TORRENT_EXPORT void assert_print(char const* fmt, ...) { -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS if (assert_counter > 500) return; FILE* out = fopen(libtorrent_assert_log, "a+"); @@ -235,15 +236,15 @@ TORRENT_EXPORT void assert_print(char const* fmt, ...) vfprintf(out, fmt, va); va_end(va); -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS if (out != stderr) fclose(out); #endif } -TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file - , char const* function, char const* value, int kind) +TORRENT_NO_RETURN TORRENT_EXPORT void assert_fail(char const* expr, int line + , char const* file, char const* function, char const* value, int kind) { -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS // no need to flood the assert log with infinite number of asserts if (assert_counter.fetch_add(1) + 1 > 500) return; #endif @@ -266,7 +267,7 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file } assert_print("%s\n" -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS "#: %d\n" #endif "file: '%s'\n" @@ -277,7 +278,7 @@ TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file "stack:\n" "%s\n" , message -#if TORRENT_PRODUCTION_ASSERTS +#ifdef TORRENT_PRODUCTION_ASSERTS , assert_counter.load() #endif , file, line, function, expr diff --git a/src/close_reason.cpp b/src/close_reason.cpp index b5a0b26ef..6d5be88ca 100644 --- a/src/close_reason.cpp +++ b/src/close_reason.cpp @@ -33,9 +33,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/close_reason.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/assert.hpp" +#include "libtorrent/error_code.hpp" +#include "aux_/disable_warnings_push.hpp" + +#include #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { diff --git a/src/crc32c.cpp b/src/crc32c.cpp index 8e6e5ccae..48d137320 100644 --- a/src/crc32c.cpp +++ b/src/crc32c.cpp @@ -33,8 +33,12 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/crc32c.hpp" #include "libtorrent/cpuid.hpp" +#include "aux_/disable_warnings_push.hpp" + #include +#include "aux_/disable_warnings_pop.hpp" + namespace libtorrent { bool supports_sse42() diff --git a/src/escape_string.cpp b/src/escape_string.cpp index d5c87505a..30c281409 100644 --- a/src/escape_string.cpp +++ b/src/escape_string.cpp @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -40,11 +42,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include "libtorrent/config.hpp" -#include "libtorrent/assert.hpp" -#include "libtorrent/parse_url.hpp" -#include "libtorrent/random.hpp" - #ifdef TORRENT_WINDOWS #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN @@ -52,17 +49,24 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#if TORRENT_USE_ICONV +#include +#include +#endif + +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/config.hpp" +#include "libtorrent/assert.hpp" +#include "libtorrent/parse_url.hpp" +#include "libtorrent/random.hpp" + #include "libtorrent/utf8.hpp" #include "libtorrent/thread.hpp" #include "libtorrent/aux_/escape_string.hpp" #include "libtorrent/string_util.hpp" // for to_string -#if TORRENT_USE_ICONV -#include -#include -#endif - namespace libtorrent { diff --git a/src/file.cpp b/src/file.cpp index bfe061ada..d145c9308 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS #include #include "libtorrent/thread.hpp" #endif @@ -1285,7 +1285,7 @@ namespace libtorrent { close(); -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS m_file_path = path; #endif @@ -1471,7 +1471,7 @@ namespace libtorrent return true; } -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS void file::print_info(FILE* out) const { if (!is_open()) return; @@ -2201,7 +2201,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { #endif } -#if TORRENT_DEBUG_FILE_LEAKS +#ifdef TORRENT_DEBUG_FILE_LEAKS std::set global_file_handles; mutex file_handle_mutex; diff --git a/src/identify_client.cpp b/src/identify_client.cpp index a5583dfb5..81750f5be 100644 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -34,15 +34,11 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/identify_client.hpp" #include "libtorrent/fingerprint.hpp" diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index ee6e353fb..6634ad6d2 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -30,10 +30,14 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/io.hpp" #include "libtorrent/bencode.hpp" #include "libtorrent/hasher.hpp" diff --git a/src/lt_trackers.cpp b/src/lt_trackers.cpp index 409877bb7..b0f27e254 100644 --- a/src/lt_trackers.cpp +++ b/src/lt_trackers.cpp @@ -32,22 +32,18 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #include #include #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/hasher.hpp" diff --git a/src/metadata_transfer.cpp b/src/metadata_transfer.cpp index f442ee885..c5b8cc356 100644 --- a/src/metadata_transfer.cpp +++ b/src/metadata_transfer.cpp @@ -33,22 +33,18 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #include #include #include #include // count +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/hasher.hpp" diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 838e84dda..54bf6d316 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -30,11 +30,23 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include +#ifdef TORRENT_DEBUG +#include +#endif + +#ifdef TORRENT_USE_OPENSSL +#include +#endif + +#include "aux_/disable_warnings_pop.hpp" + #ifndef TORRENT_DISABLE_LOGGING #include // for va_start, va_end #include // for vsnprintf @@ -72,14 +84,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/close_reason.hpp" #include "libtorrent/aux_/time.hpp" -#ifdef TORRENT_DEBUG -#include -#endif - -#ifdef TORRENT_USE_OPENSSL -#include -#endif - //#define TORRENT_CORRUPT_DATA using boost::shared_ptr; diff --git a/src/peer_list.cpp b/src/peer_list.cpp index a295ce299..0242d4a35 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -30,16 +30,12 @@ POSSIBILITY OF SUCH DAMAGE. */ -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/peer_connection.hpp" #include "libtorrent/web_peer_connection.hpp" diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index ec8b4ac20..8b4808bc6 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -39,6 +41,8 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/piece_picker.hpp" #include "libtorrent/bitfield.hpp" #include "libtorrent/random.hpp" diff --git a/src/random.cpp b/src/random.cpp index 44a2d5881..a46a76f50 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -33,10 +33,15 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/config.hpp" #include "libtorrent/random.hpp" #include "libtorrent/assert.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include #include #include +#include "aux_/disable_warnings_pop.hpp" + #if !TORRENT_THREADSAFE_STATIC #include "libtorrent/thread.hpp" #endif diff --git a/src/session_impl.cpp b/src/session_impl.cpp index ef8e8a81c..b97b52927 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -43,22 +45,20 @@ POSSIBILITY OF SUCH DAMAGE. #endif #endif // TORRENT_DEBUG && !TORRENT_DISABLE_INVARIANT_CHECKS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include #include #include +#ifndef TORRENT_WINDOWS +#include +#endif + #ifdef TORRENT_USE_VALGRIND #include #endif -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/torrent_info.hpp" @@ -95,10 +95,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/torrent_peer.hpp" #include "libtorrent/choker.hpp" -#ifndef TORRENT_WINDOWS -#include -#endif - #ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/socket_io.hpp" diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 7edf78d8a..f4fa4a6ef 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -32,23 +32,19 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #include #include #include #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/hasher.hpp" #include "libtorrent/torrent.hpp" #include "libtorrent/extensions.hpp" diff --git a/src/storage.cpp b/src/storage.cpp index b4aa4e0c2..2107c2227 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -30,15 +30,13 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include #include @@ -47,28 +45,6 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#include "libtorrent/config.hpp" -#include "libtorrent/storage.hpp" -#include "libtorrent/torrent.hpp" -#include "libtorrent/hasher.hpp" -#include "libtorrent/session.hpp" -#include "libtorrent/peer_id.hpp" -#include "libtorrent/file.hpp" -#include "libtorrent/invariant_check.hpp" -#include "libtorrent/file_pool.hpp" -#include "libtorrent/aux_/session_impl.hpp" -#include "libtorrent/disk_buffer_holder.hpp" -#include "libtorrent/alloca.hpp" -#include "libtorrent/stat_cache.hpp" - -#include - -//#define TORRENT_PARTIAL_HASH_LOG - #if defined(__APPLE__) // for getattrlist() #include @@ -88,6 +64,26 @@ POSSIBILITY OF SUCH DAMAGE. #include #endif +#include "aux_/disable_warnings_pop.hpp" + +#include "libtorrent/config.hpp" +#include "libtorrent/storage.hpp" +#include "libtorrent/torrent.hpp" +#include "libtorrent/hasher.hpp" +#include "libtorrent/session.hpp" +#include "libtorrent/peer_id.hpp" +#include "libtorrent/file.hpp" +#include "libtorrent/invariant_check.hpp" +#include "libtorrent/file_pool.hpp" +#include "libtorrent/aux_/session_impl.hpp" +#include "libtorrent/disk_buffer_holder.hpp" +#include "libtorrent/alloca.hpp" +#include "libtorrent/stat_cache.hpp" + +#include + +//#define TORRENT_PARTIAL_HASH_LOG + // for convert_to_wstring and convert_to_native #include "libtorrent/aux_/escape_string.hpp" diff --git a/src/torrent.cpp b/src/torrent.cpp index f01b3a285..b177be2d9 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -30,6 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "libtorrent/config.hpp" + +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -37,18 +41,20 @@ POSSIBILITY OF SUCH DAMAGE. #include #include // for numeric_limits -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#ifdef TORRENT_USE_OPENSSL +#include "libtorrent/ssl_stream.hpp" +#include +#include +#if BOOST_VERSION >= 104700 +#include +#endif // BOOST_VERSION +#endif // TORRENT_USE_OPENSSL + +#include "aux_/disable_warnings_pop.hpp" -#include "libtorrent/config.hpp" #include "libtorrent/torrent_handle.hpp" #include "libtorrent/session.hpp" #include "libtorrent/torrent_info.hpp" @@ -88,15 +94,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/alloca.hpp" #include "libtorrent/resolve_links.hpp" -#ifdef TORRENT_USE_OPENSSL -#include "libtorrent/ssl_stream.hpp" -#include -#include -#if BOOST_VERSION >= 104700 -#include -#endif // BOOST_VERSION -#endif // TORRENT_USE_OPENSSL - #ifndef TORRENT_DISABLE_LOGGING #include "libtorrent/aux_/session_impl.hpp" // for tracker_logger #endif diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 2a6219dd9..fc09ebb8f 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -30,6 +30,8 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include @@ -37,16 +39,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/peer_id.hpp" #include "libtorrent/bt_peer_connection.hpp" diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index 1e5a7aff2..07df98b3b 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -30,12 +30,16 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/tracker_manager.hpp" #include "libtorrent/http_tracker_connection.hpp" #include "libtorrent/udp_tracker_connection.hpp" diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index b078c211f..eb9f4aac3 100644 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -30,19 +30,15 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include "aux_/disable_warnings_push.hpp" + #include #include -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif - #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/tracker_manager.hpp" #include "libtorrent/parse_url.hpp" diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index c6d9b91fe..120074181 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -32,22 +32,18 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #include #include #include #include +#include "aux_/disable_warnings_pop.hpp" + #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp" #include "libtorrent/hasher.hpp" diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 32eab15f4..5000da3d3 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -32,15 +32,11 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_DISABLE_EXTENSIONS -#ifdef _MSC_VER -#pragma warning(push, 1) -#endif +#include "aux_/disable_warnings_push.hpp" #include -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#include "aux_/disable_warnings_pop.hpp" #include "libtorrent/peer_connection.hpp" #include "libtorrent/bt_peer_connection.hpp"