/[ascend]/trunk/base/generic/utilities/ascPanic.h
ViewVC logotype

Diff of /trunk/base/generic/utilities/ascPanic.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 975 by johnpye, Sat Dec 9 02:20:15 2006 UTC revision 976 by johnpye, Tue Dec 19 13:52:51 2006 UTC
# Line 32  Line 32 
32  #ifndef ASC_ASCPANIC_H  #ifndef ASC_ASCPANIC_H
33  #define ASC_ASCPANIC_H  #define ASC_ASCPANIC_H
34    
35  #ifndef __FUNCTION__  #ifndef __GNUC__
36  # define __FUNCTION__ "<unknown>"  # ifndef __FUNCTION__
37    #  define __FUNCTION__ NULL
38    # endif
39    #endif
40    
41    NORETURN ASC_DLLSPEC(void) asc_panic_line(
42            const int status, const char *file, const int line, const char *function,
43            const char *format, ...
44    );
45    
46    /* for 'Asc_Panic', use a var-args macro to get local line numbers if possible */
47    
48    #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
49    # define Asc_Panic(STAT,FUNC,ARGS...) asc_panic_line(STAT,__FILE__,__LINE__,__func__, ##ARGS)
50    #else
51    # define Asc_Panic asc_panic
52    
53    NORETURN ASC_DLLSPEC(void) asc_panic(
54            CONST int status, CONST char *function,
55            CONST char *format, ...
56    );
57    
58  #endif  #endif
59    
60  /**  /**
61      Our assert macro. Uses Asc_Panic() to report & handle assertion failure. Disabled if ASC_NO_ASSERTIONS is defined.      Our assertion macros. Use asc_panic_line to report & handle assertion failure. Disabled if ASC_NO_ASSERTIONS is defined.
62  */  */
63  #ifdef ASC_NO_ASSERTIONS  #ifdef ASC_NO_ASSERTIONS
64  # define asc_assert(x) ((void)0)  # define asc_assert(x) ((void)0)
65    
66  #else  #else
67  # define asc_assert(cond) \  # define asc_assert(cond) \
68      ((cond) ? (void)0 : Asc_Panic(ASCERR_ASSERTION_FAILED, NULL, \      ((cond) ? (void)0 : asc_panic_line(ASCERR_ASSERTION_FAILED\
69          "Assertion failed in %s:%d:  '%s'", __FILE__, __LINE__, #cond))          , __FILE__, __LINE__, __FUNCTION__\
70            ,"Assertion failed: %s", #cond))
71    
72    #define ASC_ASSERT_LT(A,B) \
73        (((A)<(B)) ? (void)0 : asc_panic_line(ASCERR_ASSERTION_FAILED\
74            , __FILE__, __LINE__, __FUNCTION__\
75            ,"Assertion failed: %s < %s (lhs = %f, rhs = %f)" \
76            , #A, #B \
77            , (float)A, (float)B))
78    
79    #define ASC_ASSERT_EQ(A,B) \
80        (((A)==(B)) ? (void)0 : asc_panic_line(ASCERR_ASSERTION_FAILED\
81            , __FILE__, __LINE__, __FUNCTION__\
82            ,"Assertion failed: %s < %s (lhs = %f, rhs = %f)" \
83            , #A, #B \
84            , (float)A, (float)B))
85    
86  #endif  #endif
87    
 NORETURN ASC_DLLSPEC(void) Asc_Panic(  
         CONST int status, CONST char *function,  
         CONST char *format, ...  
 );  
88  /**< Print fatal error message, run callback function & (usually) exit the program.  /**< Print fatal error message, run callback function & (usually) exit the program.
89    
90      @param status   Status code passed by the calling function.      @param status   Status code passed by the calling function.

Legend:
Removed from v.975  
changed lines
  Added in v.976

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22