aboutsummaryrefslogtreecommitdiff
path: root/util.h
blob: eb250aea78ca295d9cf6236618d1084a59f316fb (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
32
#ifndef ITS1_UTIL_H_INCLUDED
#define ITS1_UTIL_H_INCLUDED

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.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]))
#endif

#endif