Provisional error messages with abort().
Former-commit-id: eba2bd11556cb9f39fb344f9867102f29229455d
This commit is contained in:
parent
12e0188c6d
commit
c86376d435
|
@ -0,0 +1,48 @@
|
|||
#include "qpms_error.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void qpms_pr_error(const char *fmt, ...) {
|
||||
fflush(stdout);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
//void qpms_error(const char *fmt, ...);
|
||||
|
||||
void qpms_pr_error_at_line(const char *filename, unsigned int linenum,
|
||||
const char *fmt, ...) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s:%u: ", filename, linenum);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
|
||||
void qpms_pr_error_at_flf(const char *filename, unsigned int linenum,
|
||||
const char *func,
|
||||
const char *fmt, ...) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s:%u, %s: ", filename, linenum, func);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
fflush(stderr);
|
||||
abort();
|
||||
}
|
||||
//void qpms_error_at_line(const char *filename, unsigned int linenum,
|
||||
// const char *fmt, ...);
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef QPMS_ERROR_H
|
||||
#define QPMS_ERROR_H
|
||||
|
||||
/// Provisional error message with abort();
|
||||
void qpms_pr_error(const char *fmt, ...);
|
||||
//void qpms_error(const char *fmt, ...);
|
||||
|
||||
/// Provisional error message with abort(), indicating source and line number.
|
||||
void qpms_pr_error_at_line(const char *filename, unsigned int linenum,
|
||||
const char *fmt, ...);
|
||||
|
||||
void qpms_pr_error_at_flf(const char *filename, unsigned int linenum,
|
||||
const char *func,
|
||||
const char *fmt, ...);
|
||||
|
||||
//void qpms_error_at_line(const char *filename, unsigned int linenum,
|
||||
// const char *fmt, ...);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue