aboutsummaryrefslogtreecommitdiff
path: root/util.h
blob: 614c4b0d38490247d3c3406d921f55990b76955b (plain)
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
#ifndef ITS1_UTIL_H_INCLUDED
#define ITS1_UTIL_H_INCLUDED

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

#ifndef NDEBUG
static void
error(const char *msg, ...)
{
	va_list ap;

	va_start(ap, msg);
	fprintf(stderr, "Error: ");
	vfprintf(stderr, msg, ap);
	va_end(ap);
	fprintf(stderr, "\n");
	exit(EXIT_FAILURE);
}

#	define ERROR(msg) error(msg " in \"%s()\" (%s:%d)", __func__, __FILE__, __LINE__)
#else
#	define ERROR(msg) /**/
#endif

#ifndef NELEM
#	define NELEM(x) (sizeof(x) / sizeof(x[0])) /* NOLINT */
#endif

#endif