1 Star 0 Fork 12

earth_mark/cmd-parser

forked from 杰杰/cmd-parser 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cmd.h 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* @Author: jiejie
* @Github: https://github.com/jiejieTop
* @Date: 2019-12-13 10:48:52
* @LastEditTime: 2019-12-16 21:26:56
* @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
*/
#ifndef _CMD_H_
#define _CMD_H_
#define CMD_HASH 0xb433e5c6
#if defined(__CC_ARM) || defined(__CLANG_ARM) /* ARM Compiler */
#define SECTION(x) __attribute__((section(x)))
#define CMD_USED __attribute__((used))
#elif defined (__IAR_SYSTEMS_ICC__) /* IAR Compiler */
#define SECTION(x) @ x
#define CMD_USED __root
#else
#error "not supported tool chain..."
#endif
typedef void (*cmd_handler)(void);
typedef struct cmd {
const char* cmd;
unsigned int hash;
cmd_handler handler;
} cmd_t;
#define REGISTER_CMD(cmd, handler) \
const char _register_##cmd##_cmd[] = #cmd; \
CMD_USED cmd_t _register_##cmd SECTION("CMDS")= \
{ \
_register_##cmd##_cmd, \
(unsigned int)CMD_HASH, \
(cmd_handler)&handler \
};
void cmd_init(void);
void cmd_parsing(char *str);
#endif
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/earth_mark/cmd-parser.git
git@gitee.com:earth_mark/cmd-parser.git
earth_mark
cmd-parser
cmd-parser
master

搜索帮助