*optimized for embedded systems.

This commit is contained in:
Wang Renxin 2017-05-13 13:36:04 +08:00
parent 94ab881209
commit f3b8fa1905
4 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,6 @@
May. 13 2017
Added an MB_ENABLE_FULL_ERROR macro
May. 12 2017
Fixed a wrong multi-line enabled bug when met unexpected token

Binary file not shown.

View File

@ -224,6 +224,7 @@ typedef struct _ht_node_t {
/** Normal enum/struct/union/const, etc. */
#ifdef MB_ENABLE_FULL_ERROR
/* Error description text */
MBCONST static const char* const _ERR_DESC[] = {
"No error",
@ -321,6 +322,7 @@ MBCONST static const char* const _ERR_DESC[] = {
};
mb_static_assert(countof(_ERR_DESC) == SE_COUNT);
#endif /* MB_ENABLE_FULL_ERROR */
/* Data type */
typedef enum _data_e {
@ -13538,10 +13540,16 @@ _exit:
/* Get the error description text */
const char* mb_get_error_desc(mb_error_e err) {
#ifdef MB_ENABLE_FULL_ERROR
if(err < countof(_ERR_DESC))
return _ERR_DESC[err];
return "";
return "Unknown error";
#else /* MB_ENABLE_FULL_ERROR */
mb_unrefvar(err);
return "Error occurred";
#endif /* MB_ENABLE_FULL_ERROR */
}
/* Set an error handler to a MY-BASIC environment */

View File

@ -180,6 +180,10 @@ extern "C" {
# define MB_CONVERT_TO_INT_LEVEL MB_CONVERT_TO_INT_LEVEL_ALL
#endif /* MB_CONVERT_TO_INT_LEVEL */
#ifndef MB_ENABLE_FULL_ERROR
# define MB_ENABLE_FULL_ERROR
#endif /* MB_ENABLE_FULL_ERROR */
#ifndef MB_COMPACT_MODE
# define MB_COMPACT_MODE
#endif /* MB_COMPACT_MODE */