vs 中 编译c++多文件程序, 为什么在编译阶段不出错,却在连接阶段出错了呢
清水迎朝阳 博客专家认证 2008-11-22 05:01:54 出错信息 变量我只在一个文件中声明了 而且这个文件也保证在主文件中只被包含进一次
我就是一个 Queue.h // 定义队列结构 和参数
一个 function.cpp // 定义函数
一个 PT.cpp // main 函数
包含关系 function.cpp 文件中 : include"Queue.h"
PT.cpp : include"function.cpp"
并没有重复包含啊 为什么编译没事 链接时出现如下错误, 没发现多重定义啊
1>正在编译...
1>PT.cpp
1>d:\grid\pt\pt\pt\function.cpp(145) : warning C4715: “intersect”: 不是所有的控件路径都返回值
1>正在链接...
1>function.obj : error LNK2005: "void __cdecl InitQueue(struct SeqQueue *)" (?InitQueue@@YAXPAUSeqQueue@@@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "bool __cdecl DeQueue(struct SeqQueue *,struct QueueElementType *)" (?DeQueue@@YA_NPAUSeqQueue@@PAUQueueElementType@@@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "void __cdecl GetHead(struct SeqQueue *,struct QueueElementType *)" (?GetHead@@YAXPAUSeqQueue@@PAUQueueElementType@@@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "bool __cdecl intersect(struct QueueElementType,struct QueueElementType)" (?intersect@@YA_NUQueueElementType@@0@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "bool __cdecl intersect(struct QueueElementType,struct square_A)" (?intersect@@YA_NUQueueElementType@@Usquare_A@@@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "bool __cdecl inter(struct QueueElementType,struct QueueElementType)" (?inter@@YA_NUQueueElementType@@0@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double __cdecl area_nonself(struct QueueElementType * const)" (?area_nonself@@YAOQAUQueueElementType@@@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double __cdecl _max(long double * const)" (?_max@@YAOQAO@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double __cdecl _min(long double * const)" (?_min@@YAOQAO@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double __cdecl mean(long double * const)" (?mean@@YAOQAO@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double __cdecl sd(long double * const,long double)" (?sd@@YAOQAOO@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "bool __cdecl EnQueue(struct SeqQueue *,struct QueueElementType)" (?EnQueue@@YA_NPAUSeqQueue@@UQueueElementType@@@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "void __cdecl detec(long double,long double,long double)" (?detec@@YAXOOO@Z) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "struct SeqQueue * p1" (?p1@@3PAUSeqQueue@@A) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "struct SeqQueue Q" (?Q@@3USeqQueue@@A) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double rs" (?rs@@3OA) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double r0" (?r0@@3OA) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "struct QueueElementType * self" (?self@@3PAUQueueElementType@@A) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "struct square_A * test" (?test@@3PAUsquare_A@@A) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "int n_time" (?n_time@@3HA) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "int n_r" (?n_r@@3HA) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double s_all" (?s_all@@3OA) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "long double sum" (?sum@@3OA) 已经在 PT.obj 中定义
1>function.obj : error LNK2005: "class std::vector<struct QueueElementType,class std::allocator<struct QueueElementType> > detector" (?detector@@3V?$vector@UQueueElementType@@V?$allocator@UQueueElementType@@@std@@@std@@A) 已经在 PT.obj 中定义
1>D:\grid\PT\PT\Debug\PT.exe : fatal error LNK1169: 找到一个或多个多重定义的符号