2 c++ reference nintendo-ds undefined
我正在尝试Nintendo DS编程,我有一个main.cpp文件,一个snake.h文件和一个snake.cpp文件.当我编译(使用Makefile)时,我得到了
/home/david/Dropbox/sources/ds/04_snake/source/snake.cpp:228: undefined reference to `printBlock(int, int, unsigned short, int)'
/home/david/Dropbox/sources/ds/04_snake/source/snake.cpp:230: undefined reference to `printBlock(int, int, unsigned short, int)'
Run Code Online (Sandbox Code Playgroud)
这是函数中的错误
void drawSnake(game g) {
int i;
printBlock(g->s->last[0], g->s->last[1], g->bgColor, g->block);
for(i=0; g->s->points[i][0]!=-1 && i<MAXLENGHT; i++)
printBlock(g->s->points[i][0], g->s->points[i][1], g->s->color, g->block);
return;
}
Run Code Online (Sandbox Code Playgroud)
但是在同一个文件中,我有大约100行
int printBlock(game g, int x, int y, u16 color, int thickness) { /*code*/ }
Run Code Online (Sandbox Code Playgroud)
如果我注释我使用printBlock的行(在drawSnake函数中),代码编译没有错误.我试图改变名称,改变位置,但我无法理解为什么只有那个函数给我错误.
That's a different function (five arguments instead of four).
You probably meant to call it like this:
printBlock(g, g->s->points[i][0], ...
^ THIS
Run Code Online (Sandbox Code Playgroud)
(The same goes for the other call site.)