File: TTassert.h

package info (click to toggle)
twin 0.4.0-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,804 kB
  • ctags: 23,904
  • sloc: ansic: 61,860; cpp: 1,023; makefile: 777; sh: 552; lex: 302; yacc: 231
file content (43 lines) | stat: -rw-r--r-- 1,238 bytes parent folder | download | duplicates (2)
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

#ifndef _TT_ASSERT_H
#define	_TT_ASSERT_H

/* this prints an "assertion failed" message. */
void TTAssertFail (char *assertion, char *file, unsigned int line, char *function);

# define TTAssertAlways(expr)						\
    ((expr) ? 1 :							\
	 (TTAssertFail (TT_STR(expr),					\
			    __FILE__, __LINE__, TT_ASSERT_FUNCTION), 0))


# ifdef TT_ASSERT_NDEBUG
#  define TTAssert(expr) (expr)
#else
#  define TTAssert(expr) TTAssertAlways(expr)
#endif


/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
   which contains the name of the function currently being defined.
#  define __ASSERT_FUNCTION	__PRETTY_FUNCTION__
   This is broken in G++ before version 2.6.
   C9x has a similar variable called __func__, but prefer the GCC one since
   it demangles C++ function names.  */
# ifdef __GNUC__
#  if __GNUC__ > 2 || (__GNUC__ == 2 \
		       && __GNUC_MINOR__ >= (defined __cplusplus ? 6 : 4))
#   define TT_ASSERT_FUNCTION	__PRETTY_FUNCTION__
#  else
#   define TT_ASSERT_FUNCTION	((char *) 0)
#  endif
# else
#  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
#   define TT_ASSERT_FUNCTION	__func__
#  else
#   define TT_ASSERT_FUNCTION	((char *) 0)
#  endif
# endif

#endif /* _TT_ASSERT_H */