2 * Test error() and error_at_line(). Non-standard, GNU only.
4 * Copyright (C) 2013 Simon Ruderich
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #define _GNU_SOURCE /* for program_invocation_name */
26 void (*error_print_progname)(void);
29 static void print_prognmae(void) {
30 fprintf(stderr, "PROG");
34 int main(int argc, char **argv) {
35 program_invocation_name = "./example_error";
37 error(0, 0, "<message>");
38 error_at_line(0, 0, "file", 42, "<message>");
40 error(0, ENOMEM, "<message>");
41 error_at_line(0, ENOMEM, "file", 42, "<message>");
42 error_at_line(0, ENOMEM, "file", 42, "<message>");
44 error_print_progname = print_prognmae;
45 error_one_per_line = 1;
47 error(0, 0, "<message>");
48 error_at_line(0, 0, "file", 42, "<message>");
50 error(0, ENOMEM, "<message>");
51 error_at_line(0, ENOMEM, "file", 42, "<message>");
52 error_at_line(0, ENOMEM, "file", 42, "<message>");
54 /* Exit codes are not tested. */