PACK_ENUM
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user