Mercurial > code
comparison err.h @ 66:f773c76b1f3c
Added extern C tests
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 09 Nov 2011 21:08:43 +0100 |
parents | ed6ae3b865c9 |
children | 6a9ff80949f5 |
comparison
equal
deleted
inserted
replaced
65:b2cd1fd33bb0 | 66:f773c76b1f3c |
---|---|
19 #ifndef _ERR_H_ | 19 #ifndef _ERR_H_ |
20 #define _ERR_H_ | 20 #define _ERR_H_ |
21 | 21 |
22 #include <stdarg.h> | 22 #include <stdarg.h> |
23 | 23 |
24 #ifdef __cplusplus | |
25 extern "C" { | |
26 #endif | |
27 | |
24 /* | 28 /* |
25 * Attribute noreturn may helps. This may produce a warning with GCC 4.5: | 29 * Attribute noreturn may helps. This may produce a warning with GCC 4.5: |
26 * | 30 * |
27 * int a; | 31 * int a; |
28 * | 32 * |
32 * Because compilator does not know that errx will call exit may produce | 36 * Because compilator does not know that errx will call exit may produce |
33 * a warning like `a may be used uninitialized'. | 37 * a warning like `a may be used uninitialized'. |
34 */ | 38 */ |
35 | 39 |
36 #ifdef __GNUC__ | 40 #ifdef __GNUC__ |
37 #define _NORETURN_ __attribute__ ((noreturn)) | 41 # define __at_noreturn __attribute__ ((noreturn)) |
38 #endif | 42 #endif |
39 | 43 |
40 /* | 44 /* |
41 * err() functions append the format message to the stderr FILE pointer. They | 45 * err() functions append the format message to the stderr FILE pointer. They |
42 * also append the system error using strerror(errno). Then the functions exit | 46 * also append the system error using strerror(errno). Then the functions exit |
43 * with the error code given as first argument. | 47 * with the error code given as first argument. |
44 */ | 48 */ |
45 | 49 |
46 void err(int, const char *, ...) _NORETURN_; | 50 void err(int, const char *, ...) __at_noreturn; |
47 void verr(int, const char *, va_list) _NORETURN_; | 51 void verr(int, const char *, va_list) __at_noreturn; |
48 | 52 |
49 /* | 53 /* |
50 * errx() functions are similar to err() except that they do not append the | 54 * errx() functions are similar to err() except that they do not append the |
51 * system error message. | 55 * system error message. |
52 */ | 56 */ |
53 | 57 |
54 void errx(int, const char *, ...) _NORETURN_; | 58 void errx(int, const char *, ...) __at_noreturn; |
55 void verrx(int, const char *, va_list) _NORETURN_; | 59 void verrx(int, const char *, va_list) __at_noreturn; |
56 | 60 |
57 /* | 61 /* |
58 * warn() functions are similar to err() but they do not call exit(). | 62 * warn() functions are similar to err() but they do not call exit(). |
59 */ | 63 */ |
60 | 64 |
67 */ | 71 */ |
68 | 72 |
69 void warnx(const char *, ...); | 73 void warnx(const char *, ...); |
70 void vwarnx(const char *, va_list); | 74 void vwarnx(const char *, va_list); |
71 | 75 |
76 #ifdef __cplusplus | |
77 } | |
78 #endif | |
79 | |
72 #endif /* _ERR_H_ */ | 80 #endif /* _ERR_H_ */ |