製作方法打電話時我發現了一個很奇怪的錯誤:獲得離奇的「預期主表達式」錯誤
/* input.cpp */
#include <ncurses/ncurses.h>
#include "input.h"
#include "command.h"
Input::Input()
{
raw();
noecho();
}
Command Input::next()
{
char input = getch();
Command nextCommand;
switch (input)
{
case 'h':
nextCommand.setAction (ACTION_MOVELEFT);
break;
case 'j':
nextCommand.setAction (ACTION_MOVEDOWN);
break;
case 'k':
nextCommand.setAction (ACTION_MOVEUP);
break;
case 'l':
nextCommand.setAction (ACTION_MOVERIGHT);
break;
case 'y':
nextCommand.setAction (ACTION_MOVEUPLEFT);
break;
case 'u':
nextCommand.setAction (ACTION_MOVEUPRIGHT);
break;
case 'n':
nextCommand.setAction (ACTION_MOVEDOWNLEFT);
break;
case 'm':
nextCommand.setAction (ACTION_MOVEDOWNRIGHT);
break;
case '.':
nextCommand.setAction (ACTION_WAIT);
break;
}
return nextCommand;
}
和錯誤:
[email protected] ~/code/rogue2
$ make
g++ -c -Wall -pedantic -g3 -O0 input.cpp
input.cpp: In member function `Command Input::next()':
input.cpp:21: error: expected primary-expression before '=' token
input.cpp:24: error: expected primary-expression before '=' token
input.cpp:27: error: expected primary-expression before '=' token
input.cpp:30: error: expected primary-expression before '=' token
input.cpp:33: error: expected primary-expression before '=' token
input.cpp:36: error: expected primary-expression before '=' token
input.cpp:39: error: expected primary-expression before '=' token
input.cpp:42: error: expected primary-expression before '=' token
input.cpp:45: error: expected primary-expression before '=' token
make: *** [input.o] Error 1
對不起缺乏linenumbers的,錯誤發生在「nextCommand.setAction(...)」行上,考慮到它們不包含'=',這完全是奇怪的。
任何想法? 謝謝,
里斯
全部大小的宏中是否存在標識符,如果是,它們是什麼擴展? – 2010-04-19 01:26:42