Top > C++ > apcl > debug > Assert

Assert Edit

概要 Edit

printfのメッセージがつけられるアサーション。
Releaseモードでもメッセージをはくアサートも用意。

履歴 Edit

  • revision 8 : 作成

コード Edit

ヘッダファイル Edit

fileAssert.hpp
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
-
|
|
|
|
|
|
|
|
|
!
 
 
 
 
 
 
 
 
 
 
-
|
|
|
|
|
|
|
|
|
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** 
 * @file 
 * assertLqB
 */
#pragma once
 
//-----------------------------------------------------------
#include <cassert>
#include <cstdio>
 
//-----------------------------------------------------------
 
/**
 * Release[hł@\郁bZ[WtAT[gB
 * <pre>
 * ERelease[h͕\͂邪t[Y͂ȂB
 * EbZ[Wprintf̏B
 * </pre>
 */
#define apclAssertRMsg( cmd , ... ) \
  if( !(cmd) ) \
  { \
    ::std::printf( "############################################################\n" ); \
    ::std::printf( "[APCL Assertion Failed]\nFile:%s\nLine:%d\n" , __FILE__ , __LINE__ ); \
    ::std::printf( #cmd ); \
    ::std::printf( "\n" ); \
    ::std::printf( "Message:" ); \
    ::std::printf( __VA_ARGS__ ); \
    ::std::printf( "\n" ); \
    ::std::printf( "############################################################\n" ); \
    assert( cmd ); \
  } \
 
/// Release[hł@\AT[gBRelease[h͕\͂邪t[Y͂ȂB
#define apclAssertR( cmd ) \
  apclAssertRMsg( cmd , "None" )
 
/// fobO[hpbZ[WtAT[gBbZ[Wprintf̏B
//@{
#ifdef _DEBUG
#define apclAssertMsg( cmd , ... ) \
  if( !(cmd) ) \
  { \
    ::std::printf( "############################################################\n" ); \
    ::std::printf( "[APCL Assertion Failed]\nFile:%s\nLine:%d\n" , __FILE__ , __LINE__ ); \
    ::std::printf( #cmd ); \
    ::std::printf( "\n" ); \
    ::std::printf( "Message:" ); \
    ::std::printf( __VA_ARGS__ ); \
    ::std::printf( "\n" ); \
    ::std::printf( "############################################################\n" ); \
    assert( cmd ); \
  } \
 
#else
#define apclAssertMsg( cmd , ... ) \  
  ((void)0)
 
#endif // _DEBUG
//@}
 
/// fobO[hpAT[gB
//@{
#ifdef _DEBUG
#define apclAssert( cmd ) \
  apclAssertMsg( cmd , "None" )
 
#else // _DEBUG
#define apclAssert( cmd ) 
  ((void)0)
 
#endif // _DEBUG
//@}
 
 
//-----------------------------------------------------------
// EOF

ソースファイル Edit

fileAssert.cpp
Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
 
 
 
 
 
 
 
 
/** 
 * @file 
 * Assert.hpp̎LqB
 */
#include <apcl/debug/Assert.hpp>
 
//-----------------------------------------------------------
// EOF

Attach file: fileAssert.cpp 519 download [Information] fileAssert.hpp 666 download [Information]

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup Referer   Help   RSS of recent changes
Last-modified: (5879d)