相关疑难解决方法(0)

"多重定义","此处首先定义"错误

我有3个项目:服务器,客户端共享.在Commons中创建头和源对不会导致任何问题,我可以从服务器客户端自由访问这些功能.

然而,由于某些原因使中附加源/头文件服务器客户端的项目总是会引起multiple definition of (...)first defined here错误.

例:

commands.h(在Client项目的根目录中)

#ifndef COMMANDS_H_
#define COMMANDS_H_

#include "commands.c"

void f123();

#endif /* COMMANDS_H_ */
Run Code Online (Sandbox Code Playgroud)

commands.c(在Client项目的根目录中)

void f123(){

}
Run Code Online (Sandbox Code Playgroud)

main.c(在Client项目的根目录中)

#include "commands.h"
int main(int argc, char** argv){

}
Run Code Online (Sandbox Code Playgroud)

错误:

make: *** [Client] Error 1      Client
first defined here              Client
multiple definition of `f123'   commands.c
Run Code Online (Sandbox Code Playgroud)

清洁,重建索引,重建项目没有帮助.也没有重新启动计算机.

c eclipse definition include multiple-definition-error

15
推荐指数
3
解决办法
8万
查看次数