1 #include <iostream>
2
3 /// \file
4 /// Implementation of the assert function for MiniDNN
5 #pragma once
6
__M_Assert(const char * expr_str,bool expr,const char * file,int line,const char * msg)7 inline void __M_Assert(const char* expr_str, bool expr, const char* file,
8 int line, const char* msg)
9 {
10 if (!expr)
11 {
12 std::cerr << "Assert failed:\t" << msg << "\n"
13 << "Expected:\t" << expr_str << "\n"
14 << "Source:\t\t" << file << ", line " << line << "\n";
15 abort();
16 }
17 }
18
19 #ifndef NDEBUG
20 #define M_Assert(Expr, Msg) \
21 __M_Assert(#Expr, Expr, __FILE__, __LINE__, Msg)
22 #else
23 #define M_Assert(Expr, Msg) ;
24 #endif
25
26