C-libs 0.1.0
Some C utils libraries
 
Loading...
Searching...
No Matches
Handling Macros

Macros

#define TRY_GOTO(pred, label)
 
#define TRY_THROW(pred)
 
#define TRY_LOG(pred, msg)
 
#define TRY_EXEC(pred, block)
 

Detailed Description

Macros to simplify conditional error handling.

Macro Definition Documentation

◆ TRY_EXEC

#define TRY_EXEC ( pred,
block )
Value:
do { \
if (!(pred)) { \
do \
block while (0); \
} \
} while (0)

◆ TRY_GOTO

#define TRY_GOTO ( pred,
label )
Value:
do { \
if (!(pred)) { \
goto label; \
} \
} while (0)

◆ TRY_LOG

#define TRY_LOG ( pred,
msg )
Value:
do { \
if (!(pred)) { \
fprintf(stderr, "Error catched at %s:%s[%d]: %s", __FILENAME__, \
__func__, __LINE__, msg); \
} \
} while (0)
#define __FILENAME__
Macro to adjust the file path based on SOURCE_PATH_SIZE.
Definition logger.h:110

◆ TRY_THROW

#define TRY_THROW ( pred)
Value:
do { \
if (!(pred)) { \
exit(EXIT_FAILURE); \
} \
} while (0)