|
pink26 0.1.1
Image processing and digital topology for teaching
|
Status codes and error messages. More...
#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | P26_THREAD_LOCAL _Thread_local |
| Portability switch: storage class of the thread-local error buffer. | |
| #define | P26_PRINTF_LIKE(fmt_index, args_index) |
| Portability switch: marks a printf-like function so that GCC and Clang check its format string against its arguments (-Wformat). | |
Typedefs | |
| typedef int64_t | p26_index |
| Pixel index or size in pixels (64-bit, so large 3D images fit). | |
Enumerations | |
| enum | p26_status { P26_OK = 0 , P26_E_INVALID_ARG , P26_E_TYPE , P26_E_NOMEM , P26_E_FORMAT , P26_E_UNSUPPORTED , P26_E_IO , P26_E_OVERFLOW , P26_E_INTERNAL } |
| Result of a pink26 function. More... | |
Functions | |
| p26_status | p26_fail (p26_status status, const char *format,...) P26_PRINTF_LIKE(2 |
Records an error message for the calling thread and returns status. | |
| p26_status const char * | p26_last_error (void) |
| Returns the last message recorded by p26_fail() in the calling thread. | |
| void | p26_clear_error (void) |
| Empties the error message of the calling thread. | |
| const char * | p26_status_name (p26_status status) |
| Returns the name of a status code, e.g. | |
Status codes and error messages.
Every pink26 function that can fail returns a p26_status. On failure it also records a human-readable message (what was wrong, with which value) that p26_last_error() returns. The message buffer is thread-local, so concurrent calls from several threads do not mix their messages.
| #define P26_PRINTF_LIKE | ( | fmt_index, | |
| args_index ) |
Portability switch: marks a printf-like function so that GCC and Clang check its format string against its arguments (-Wformat).
fmt_index is the position of the format parameter, args_index that of the "...", both counted from 1. Other compilers ignore it.
| enum p26_status |
Result of a pink26 function.
P26_OK is 0; every error is non-zero.
| p26_status p26_fail | ( | p26_status | status, |
| const char * | format, | ||
| ... ) |
Records an error message for the calling thread and returns status.
Library code reports every failure with return p26_fail(...), so the status and its explanation always travel together.
| status | Status to return (normally an error code). |
| format | printf-style format of the message; then its arguments. |
status, unchanged.Messages longer than 511 characters are truncated.
| p26_status const char * p26_last_error | ( | void | ) |
Returns the last message recorded by p26_fail() in the calling thread.
| const char * p26_status_name | ( | p26_status | status | ) |
Returns the name of a status code, e.g.
"P26_E_FORMAT".
| status | Any value, valid or not. |