/* vim: ts=4 sw=4 sts=4 ff=unix fenc=utf-8 :
* =====================================================================
* sc_assert.h
* Copyright (c) 2003 - 2011 sys0tem
* LICENSE :
* LGPL (GNU Lesser General Public License - Version 3,29 June 2007)
* http://www.gnu.org/copyleft/lesser.html
* or
* EPL (Eclipse Public License - v1.0)
* http://www.eclipse.org/legal/epl-v10.html
* =====================================================================
*/
#ifndef __SC_ASSERT_H__
#define __SC_ASSERT_H__
#include <stdio.h>
#include <sc_stdbool.h>
#ifdef SC_DEBUG
#define SC_assert(val) SC_assert_(val, \
#val, __FILE__, __LINE__, SC_FUNC)
#define SC_assertNumber(val1, val2) SC_assertNumber_(val1, val2, \
#val2, __FILE__, __LINE__, SC_FUNC)
#define SC_assertString(val1, val2) SC_assertString_(val1, val2, \
#val2, __FILE__, __LINE__, SC_FUNC)
#define SC_assertMemory(val1, val2, size) SC_assertMemory_( \
val1, val2, size, \
#val2, __FILE__, __LINE__, SC_FUNC)
#else
#define SC_assert(val) SC_assertDummy_(val)
#define SC_assertNumber(val1, val2) SC_assertNumberDummy_(val1, val2)
#define SC_assertString(val1, val2) SC_assertStringDummy_(val1, val2)
#define SC_assertMemory(val1, val2, size) SC_assertMemoryDummy_(val1, val2, size)
#endif /* SC_DEBUG */
#ifdef __cplusplus
extern "C" {
#endif
void SC_setAssertOutput(FILE* fp);
void SC_clearAssertOutput(void);
bool SC_assertAtExit(void (*func)(void));
void SC_assertAtExitClear(void);
void SC_assert_(long val, const char* valName,
const char* file, int line, const char* func);
void SC_assertNumber_(long val1, long val2,
const char* valName,
const char* file, int line, const char* func);
void SC_assertString_(const char* val1, const char* val2,
const char* valName,
const char* file, int line, const char* func);
void SC_assertMemory_(const void* val1, const void* val2,
size_t size,
const char* valName,
const char* file, int line, const char* func);
void SC_assertDummy_(long val);
void SC_assertNumberDummy_(long val1, long val2);
void SC_assertStringDummy_(const char* val1, const char* val2);
void SC_assertMemoryDummy_(const void* val1, const void* val2, size_t size);
#ifdef __cplusplus
}
#endif
/* エラー表示 先頭部分フォーマット */
#ifdef SC_DEBUG_PRINT_FUNC
#define SC_FUNC __func__
#define SC_ASSERT_HEAD_FORMAT "%s:%d:%s "
#else
#define SC_FUNC ""
#define SC_ASSERT_HEAD_FORMAT "%s:%d:%s "
#endif /* SC_DEBUG_PRINT_FUNC */
#endif /* __SC_ASSERT_H__ */