#ifndef _EXCEPTION_H_
#define _EXCEPTION_H_
//----------------------------------------------------------------------------
///
/// \brief  Exeption
///
/// \date   20181017
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


//---Own------------------------------


//---Declaration--------------------------------------------------------------


// Check assertions only when its a debug compilation.
#if !defined(NDEBUG)
   #define bDebugAssert( expr, sta ) if ( ! (expr) ) exception( )
#else
   #define bDebugAssert( expr, sta )
#endif

// Always check assertions. May be disabled in the future wia macro for super
// small builds.
// assert already is a macro in cassert.c
#if (1)
   #define bAssert( expr, sta ) if(!(expr))exception(  )
   // Version with string would be 'exception( "ASRT: " # text )'
   #define bAssertMsg( expr, text ) if(!(expr))exception(  )
   #define bAssertIndexInArray(_enum, _array) bDebugAssert( (_enum) < (sizeof(_array) / sizeof(_array[0]) ), _enum )
#else
   #define bAssert(expr, val)
   #define bAssertMsg(expr, val, text)
   #define bAssertIndexInArray(_enum, _array)
#endif

extern "C"
{
   void exception() __attribute__ (( noreturn ));
};

//void exception(const char* message) __attribute__ ( ( noreturn ) );
//void exception(const char* message, int status) __attribute__ ( ( noreturn ) );


//---fin----------------------------------------------------------------------
#endif // ? ! _EXCEPTION_H_
