32#define RV_EXCEPTION ( -2 )
33#define RV_ERROR ( -1 )
55 return "Unknown error";
60#define on_fail( func_call ) if ( ( func_call ) != RV_SUCCESS )
61#define on_error( func_call ) if ( ( func_call ) == RV_ERROR )
69#define return_on_fail( func_call ) \
72 int func_call_retval = ( func_call ); \
73 on_fail ( func_call_retval ) \
75 ( void ) f_stack_trace( NULL ); \
76 return func_call_retval; \
87#define return_on_error( func_call ) \
90 int func_call_retval = ( func_call ); \
91 on_error ( func_call_retval ) \
93 ( void ) f_stack_trace( 0 ); \
94 return func_call_retval; \
99#define goto_on_fail( GOTO_LABEL, func_call ) \
102 on_fail ( func_call ) \
107#define goto_on_error( GOTO_LABEL, func_call ) \
110 on_error ( func_call ) \
117#define COLOR_WARNING FOREGROUND_RED
122 const
char *__restrict FileName,
123 const
char *__restrict FunctionName,
126 ptrdiff_t return_value,
127 const
char *__restrict format,
161 const
char *__restrict FileName,
162 const
char *__restrict FunctionName,
165 ptrdiff_t return_value,
166 const
char *__restrict format,
169#ifndef SUPPRESS_WARNINGS
174 if ( FileName != NULL )
175 fprintf( stderr,
": %s", FileName );
176 if ( FunctionName != NULL )
177 fprintf( stderr,
": %s", FunctionName );
178 if ( LineNumber > 0 )
179 fprintf( stderr,
" @ %i", LineNumber );
181 if ( PrintProgName || FileName != NULL || FunctionName != NULL || LineNumber > 0 )
182 fprintf( stderr,
": " );
185 va_start( vaList, format );
186 vfprintf( stderr, format, vaList );
190 fprintf( stderr,
": %s", strerror( err_no ) );
194 fprintf( stderr,
"\n" );
197 ( void ) ( PrintProgName );
198 ( void ) ( FileName );
199 ( void ) ( FunctionName );
200 ( void ) ( LineNumber );
241#define f_stack_trace( RETVAL ) \
242 WarnUniversal( false, NULL, NULL, -1, -1, ( ptrdiff_t ) RETVAL, "\tin %s", __func__ )
248#define ffl_stack_trace( RETVAL ) \
249 WarnUniversal( false, \
254 ( ptrdiff_t ) RETVAL, \
255 "\tin %s: %s @ %d", \
262#define warn_ret( RETVAL, ... ) \
263 WarnUniversal( true, NULL, NULL, -1, errno, ( ptrdiff_t ) RETVAL, __VA_ARGS__ )
264#define warnx_ret( RETVAL, ... ) \
265 WarnUniversal( true, NULL, NULL, -1, -1, ( ptrdiff_t ) RETVAL, __VA_ARGS__ )
268#define fwarn( ... ) \
269 ( void ) WarnUniversal( true, NULL, __func__, -1, errno, -1, __VA_ARGS__ )
270#define fwarnx( ... ) \
271 ( void ) WarnUniversal( true, NULL, __func__, -1, -1, -1, __VA_ARGS__ )
272#define fwarn_ret( RETVAL, ... ) \
273 WarnUniversal( true, NULL, __func__, -1, errno, ( ptrdiff_t ) RETVAL, __VA_ARGS__ )
274#define fwarnx_ret( RETVAL, ... ) \
275 WarnUniversal( true, NULL, __func__, -1, -1, ( ptrdiff_t ) RETVAL, __VA_ARGS__ )
277#define fflwarn( ... ) \
278 ( void ) WarnUniversal( \
279 true, __FILE_NAME__, __func__, __LINE__, errno, -1, __VA_ARGS__ )
280#define fflwarnx( ... ) \
281 ( void ) WarnUniversal( true, __FILE_NAME__, __func__, __LINE__, -1, -1, __VA_ARGS__ )
282#define fflwarn_ret( RETVAL, ... ) \
283 WarnUniversal( true, \
288 ( ptrdiff_t ) RETVAL, \
290#define fflwarnx_ret( RETVAL, ... ) \
291 WarnUniversal( true, \
296 ( ptrdiff_t ) RETVAL, \
Function and variable attributes.
#define LibraryDefined
Definition attributes.h:107
#define Cold
Definition attributes.h:59
#define PrintfLike(FORMAT_STRING, FIRST_VAR_ARG)
Tells the compiler which varargs correspond to a format string.
Definition attributes.h:39
LibraryDefined PrintfLike Cold ptrdiff_t WarnUniversal(bool PrintProgName, const char *__restrict FileName, const char *__restrict FunctionName, int LineNumber, int err_no, ptrdiff_t return_value, const char *__restrict format,...)
Definition errors.h:160
LibraryDefined const char * rv_to_string(const int rv)
Definition errors.h:43
#define COLOR_WARNING
Definition errors.h:117
#define RV_SUCCESS
Definition errors.h:34
#define RV_EXCEPTION
Definition errors.h:32
#define RV_ERROR
Definition errors.h:33
LibraryDefined const char * get_prog_name(void)
Definition filenames.h:81
#define COLOR_DEFAULT
Definition terminal_colors.h:33
LibraryDefined bool SetTerminalColor(FILE *stream, const char *Color)
Definition terminal_colors.h:79