【发布时间】:2011-12-14 01:51:58
【问题描述】:
我一直在尝试编译一个多文件项目,但是每次我尝试在 player.cpp 中使用 void 时,我都会不断收到此错误消息,似乎是在编译期间创建的 player.o void player_action(...) 的定义相同。当我尝试在其他文件中使用 void 时,会出现同样的问题,它们对应的 .o 文件。但是,如果我在任何文件中使用结构,都不会出现问题,也不会出现“多重定义”错误。下面几行是编译器给我的错误信息。
obj\Debug\player.o: In function `Z13player_actioniii':
D:/Projects/Blackmail Mailman/player.cpp:13: multiple definition of `player_action(int, int, int)'
obj\Debug\main.o:D:/Projects/Blackmail Mailman/player.cpp:13: first defined here
这是我使用的 player.cpp 中的代码:
#include "include_files.cpp"
struct player_struct
{
int x;
int y;
int previous_x;
int previous_y;
int mode;
};
void player_action(int x, int y, int mode)
{
SDL_Event event;
if (SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_RIGHT:;
};
};
};
};
可能出了什么问题,我该如何解决?我在 Mingw 和 Windows XP 中使用 Codeblocks。我已经检查了其他文件,没有任何额外的 void player_action() 定义。
【问题讨论】:
-
“使用空白”是什么意思?
-
意思是这样使用:void player_action(int x, int y){...}。
-
您可能多次包含包含函数定义的文件。没有源代码很难说。
-
您需要发布代码以获得帮助。
-
你为什么
#includeing .cpp 文件?这可能是奇怪的原因。
标签: c++ compiler-errors codeblocks