原文: assert宏实现中的注意点
实现:

#ifdef _DEBUG_
    #define ASSERT(x) \  
        do { if (!(x)) { printf("ASSERT!file: %s, line: %s\r\n",  __FILE__, __LINE__); } } while(0)  
    #define PRINT(x, y) printf(x, y)
#else  
    #define ASSERT(x) \  
        do { (void)sizeof(x); } while(0)  
    #define PRINT(x, y) (void)sizeof(x)
#endif 

#ifdef POW2_ASSERTS_ENABLED  
    #define POW2_ASSERT(x) \  
        do { if (!(x)) { pow2::Assert::Fail(#x, __FILE__, __LINE__); } } while(0)  
#else  
    #define POW2_ASSERT(x) \  
        do { (void)sizeof(x); } while(0)  
#endif   

标签: none 阅读量: 1533

添加新评论