nns.c  1.0.1
Nanowire Network simulator
errors.h File Reference

Contains an utilities to manage exceptions. Not supposed to be used directly by the user. More...

#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define assert(EVAL, ERROR_CODE, ...)
 Macro to perform condition-assertion and exit with the specific error-code in case of error. The macro expects a boolean condition as first input, a possible error code as the second and a message with possible parameters later. This macro will terminate the process execution. More...
 
#define requires(EVAL, ERROR_CODE, ...)
 Macro to perform condition-assertion and return and error-code in case of an unexpected condition. The macro expects a boolean condition as first input, a possible error code as the second and a message with possible parameters later. More...
 

Detailed Description

Contains an utilities to manage exceptions. Not supposed to be used directly by the user.

Macro Definition Documentation

◆ assert

#define assert (   EVAL,
  ERROR_CODE,
  ... 
)
Value:
({ \
if (! (EVAL)) \
{ \
printf(__VA_ARGS__); \
exit(ERROR_CODE); \
} \
})

Macro to perform condition-assertion and exit with the specific error-code in case of error. The macro expects a boolean condition as first input, a possible error code as the second and a message with possible parameters later. This macro will terminate the process execution.

Parameters
EVALThe condition expected to be true.
ERROR_CODEThe error code to return in case of error.
VARARGThe formatted error message and the referenced variables.

◆ requires

#define requires (   EVAL,
  ERROR_CODE,
  ... 
)
Value:
({ \
if (! (EVAL)) \
{ \
printf(__VA_ARGS__); \
return ERROR_CODE; \
} \
})

Macro to perform condition-assertion and return and error-code in case of an unexpected condition. The macro expects a boolean condition as first input, a possible error code as the second and a message with possible parameters later.

Parameters
EVALThe condition expected to be true.
ERROR_CODEThe error code to return in case of error.
VARARGThe formatted error message and the referenced variables.
Returns
The error code if the condition is false.