From: Grzegorz Rynkowski Date: Wed, 25 Feb 2015 17:55:03 +0000 (+0100) Subject: [common] Added assert.h X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~347 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=461c14e844895045a451ade4a8b70929f5d57ae9;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [common] Added assert.h Problem: Using plain assert does not print any information about the source of assertion. Change-Id: I66192909d6fe5836b098b0e2225a79ec1de86f8d Signed-off-by: Grzegorz Rynkowski --- diff --git a/src/common/assert.h b/src/common/assert.h new file mode 100644 index 00000000..f56ba791 --- /dev/null +++ b/src/common/assert.h @@ -0,0 +1,23 @@ +// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMMON_ASSERT_H_ +#define COMMON_ASSERT_H_ + +#include + +#include "common/logger.h" + +#define AssertMsg(condition, message) \ + do { \ + std::string msg(message); \ + if (!(condition)) \ + LoggerE("assert(%s)%s", #condition, \ + !msg.empty() ? std::string(", message: " + msg).c_str() : ""); \ + assert(!!(condition) && message); \ + } while(0) + +#define Assert(condition) AssertMsg(condition, "") + +#endif // COMMON_ASSERT_H_ \ No newline at end of file diff --git a/src/common/common.gypi b/src/common/common.gypi index 260a0fbf..d7698dff 100644 --- a/src/common/common.gypi +++ b/src/common/common.gypi @@ -101,7 +101,8 @@ #'multi_callback_user_data.cc', #'multi_callback_user_data.h', 'platform_result.cc', - 'platform_result.h' + 'platform_result.h', + 'assert.h' ], 'cflags': [ '-std=c++0x',