PACK_ENUM

This commit is contained in:
2023-01-19 20:58:30 +06:00
parent 169165ac5a
commit 31c7d4e31b
5 changed files with 15 additions and 11 deletions

View File

@@ -7,13 +7,13 @@ extern "C" {
#include "std.h"
#include "type_system/unitype.h"
typedef enum ErrorId {
PACK_ENUM(ErrorId,
SUCCESS, // not an error
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX,
ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR,
ERR_KEYNOTFOUND, ERR_FORMAT, ERR_UNEXPECTEDVAL,
ERR_IO, ERR_IO_EOF
} ErrorId;
)
char* errname(ErrorId err);

View File

@@ -118,6 +118,10 @@ You can even embed it into macro in header (see kprint.h)
CODE;\
PRAGMA_WARNING_POP
#define PACK_ENUM(ENUM_NAME, ENUM_MEMBERS...) typedef enum ENUM_NAME {\
ENUM_MEMBERS\
} __attribute__((__packed__)) ENUM_NAME;
#if __cplusplus
}
#endif