fix production assert

This commit is contained in:
Arvid Norberg 2011-08-14 23:55:41 +00:00
parent 524e116277
commit b9be2fe94b
2 changed files with 7 additions and 2 deletions

View File

@ -56,7 +56,9 @@ std::string demangle(char const* name);
#include <sstream>
#endif
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function, char const* val);
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file
, char const* function, char const* val);
#define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__, 0); } while (false)
#if TORRENT_USE_IOSTREAM
#define TORRENT_ASSERT_VAL(x, y) do { if (x) {} else { std::stringstream __s__; __s__ << #y ": " << y; assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__, __s__.str().c_str()); } } while (false)

View File

@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE.
#if defined TORRENT_DEBUG || defined TORRENT_ASIO_DEBUGGING || TORRENT_RELEASE_ASSERTS
#include "libtorrent/config.hpp"
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
@ -122,7 +124,8 @@ void print_backtrace(char* out, int len) {}
char const* libtorrent_assert_log = "asserts.log";
#endif
void assert_fail(char const* expr, int line, char const* file, char const* function, char const* value)
TORRENT_EXPORT void assert_fail(char const* expr, int line, char const* file
, char const* function, char const* value)
{
#if TORRENT_PRODUCTION_ASSERTS
FILE* out = fopen(libtorrent_assert_log, "a+");