C++ 一个简洁的CHECK宏

#include <iostream>
#include <stdlib.h>

#define CHECK2(condition, message)                                                                                                                   \
  (!(condition)) ? (std::cerr << "Assertion failed: (" << #condition << "), "                                                                        \
                              << "function " << __FUNCTION__ << ", file " << __FILE__ << ", line " << __LINE__ << "." << std::endl                   \
                              << message << std::endl,                                                                                               \
                    abort(), 0)                                                                                                                      \
                 : 1

// CHECK2(condition, "message: " << var);
posted @ 2022-10-24 14:52  山岚2013  阅读(652)  评论(0编辑  收藏  举报