在Debug模式下中断, 在Release模式下跳出当前函数的断言

在Debug模式下中断, 在Release模式下跳出当前函数的断言

#ifdef DEBUG
#define __breakPoint_on_debug asm("int3")
#else
#define __breakPoint_on_debug
#endif

// 验证
#define UXY_ASSERT_RETURN_ON_RELEASE( __condition, __desc, ... ) \
        metamacro_if_eq(0, metamacro_argcount(__VA_ARGS__)) \
        (__XY_ASSERT_1(__condition, __desc, __VA_ARGS__))    \
        (__XY_ASSERT_2(__condition, __desc, __VA_ARGS__))

#define __XY_ASSERT_1( __condition, __desc ) \
        if ( !(__condition) ) __breakPoint_on_debug;   \
        else return;

#define __XY_ASSERT_2( __condition, __desc, __returnedValue ) \
        if ( !(__condition) ) __breakPoint_on_debug;   \
        else return __returnedValue;
posted @ 2017-08-12 12:00  claireyuancy  阅读(497)  评论(0编辑  收藏  举报