通过函数指针定义,调用时加上参数

struct Command {
const char *name;
const char *desc;
// return -1 to force monitor to exit
int (*func)(int argc, char** argv, struct Trapframe* tf);
};

static struct Command commands[] = {
{ "help", "Display this list of commands", mon_help },
{ "kerninfo", "Display information about the kernel", mon_kerninfo },
{ "backtrace", "Display the current stack trace", mon_backtrace },
};

 

if (strcmp(argv[0], commands[i].name) == 0)
return commands[i].func(argc, argv, tf);

相关文章:

  • 2021-12-04
  • 2021-12-15
  • 2022-01-10
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-10-20
  • 2021-08-06
  • 2022-01-04
  • 2021-11-22
相关资源
相似解决方案