aboutsummaryrefslogtreecommitdiff
path: root/include/errors.h
blob: c8576f0d026853624dd36eb07ca4d130bdbcecab (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 MLIB_ERRORS_H
#define MLIB_ERRORS_H

#include <stdarg.h>

#include "_attrs.h"

void usage(const char *, ...);
#define usage(...) usage(__VA_ARGS__, nullptr)

[[gnu::format(printf, 1, 2)]] void warn(const char *, ...);
void vwarn(const char *, va_list);

[[noreturn, gnu::format(printf, 1, 2)]] void err(const char *, ...);
[[noreturn, gnu::format(printf, 2, 3)]] void cerr(int, const char *, ...);

extern const char *_mlib_errors_progname;

void mlib_setprogname(const char *);

[[nodiscard, _mlib_inline]]
static inline const char *
mlib_progname(void)
{
	return _mlib_errors_progname;
}

#endif /* !MLIB_ERRORS_H */