EasyAssert.h 769 字节
Newer Older
1 2 3 4 5 6 7 8
#pragma once
#include <string_view>
#include <stdio.h>
#include <stdlib.h>

/* Paste this on the file you want to debug. */

namespace milvus::impl {
9 10 11
void
EasyAssertInfo(
    bool value, std::string_view expr_str, std::string_view filename, int lineno, std::string_view extra_info);
12 13
}

14
#define AssertInfo(expr, info) milvus::impl::EasyAssertInfo(bool(expr), #expr, __FILE__, __LINE__, (info))
15
#define Assert(expr) AssertInfo((expr), "")
16 17 18 19 20
#define PanicInfo(info)                                                      \
    do {                                                                     \
        milvus::impl::EasyAssertInfo(false, (info), __FILE__, __LINE__, ""); \
        __builtin_unreachable();                                             \
    } while (0)