當我做這個存儲大小是不知道C++
我得到這個下面的錯誤「錯誤:的「mscp_commands的存儲大小是不知道」
struct command mscp_commands[]; /* forward declaration */
後來我有:
struct command mscp_commands[] = {
{ "help", cmd_help, "show this list of commands" },
{ "bd", cmd_bd, "display board" },
{ "ls", cmd_list_moves, "list moves" },
{ "new", cmd_new, "new game" },
{ "go", cmd_go, "computer starts playing" },
{ "test", cmd_test, "search (depth)" },
{ "quit", cmd_quit, "leave chess program" },
{ "sd", cmd_set_depth, "set maximum search depth (plies)" },
{ "both", cmd_both, "computer plays both sides" },
};
這有什麼錯向前聲明結構mscp_commands呀?
命令結構被前面所定義的:
struct command {
char *name;
void (*cmd)(char*);
char *help;
};
並且'struct command'的定義在哪裏?完整列出所有成員及其類型? – abelenky
如果將原型標記爲'extern',它會編譯嗎? (我不知道這是否會起作用) –