aboutsummaryrefslogtreecommitdiff
path: root/util.h
blob: 7e4df861f75355b1d9536d6345e10ee4891906fc (plain) (blame)
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
#ifndef _BRANDT_UTIL_H
#define _BRANDT_UTIL_H

void eprintf(const char *fmt, ...);
void weprintf(const char *fmt, ...);

# undef brandt_assert
# undef brandt_assert_perror
# undef brandt_assert_gpgerr

#ifdef NDEBUG

# define brandt_assert(expr)          ((void)(0))
# define brandt_assert_perror(errnum) ((void)(0))
# define brandt_assert_gpgerr(errnum) ((void)(0))

#else

# define brandt_assert(expr)          ((expr)    ? (void)(0) : \
eprintf("Assertion failed in file %s line %d function %s: %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, (#expr)))
# define brandt_assert_perror(errnum) (!(errnum) ? (void)(0) : \
eprintf("Assertion failed in file %s line %d function %s:", __FILE__, __LINE__, __PRETTY_FUNCTION__))
# define brandt_assert_gpgerr(errnum) (!(errnum) ? (void)(0) : \
eprintf("Assertion failed in file %s line %d function %s: %s", __FILE__, __LINE__, __PRETTY_FUNCTION__, gcry_strerror((errnum))))

#endif

#endif