저는 컴파일 단위와 관련된 문제를 해결하려고 노력해 왔습니다.오류 LNK2005 struct가 .obj 파일에 이미 정의되어 있습니다.
내가 점점 오전 오류이 내가 무엇입니까 유일한 오류가
1>frtinvxml.obj : error LNK2005: "struct repFieldInfo det_rep_info" ([email protected]@[email protected]@A) already defined in Frtinv.obj
1>frtinvxml.obj : error LNK2005: "struct repFieldInfo frt_rep_info" ([email protected]@[email protected]@A) already defined in Frtinv.obj
1>frtinvxml.obj : error LNK2005: "struct FormToolbar * tb" ([email protected]@[email protected]@A) already defined in Frtinv.obj
1>frtinvxml.obj : error LNK2005: "struct tagDATE_STRUCT dateFrom" ([email protected]@[email protected]@A) already defined in Frtinv.obj
... (It goes on for every variable and method in the header...)
입니다. 여기 ... (가) 트리에서 가장 낮은 순서에 관련된 각각의 클래스에 포함
***frtinv.cxx***
//#define _IN_MAIN_
#include <decisionTable.h>
...
#define RINDEX 2
#define LINDEX 2
#define PINDEX 0
BOOL s_fNeedSaveAfterDelete = FALSE;
static int rateCnt = RINDEX, lumpCnt = LINDEX, pcntCnt = PINDEX;
//------------------------------------------------------------------------
int getPortcar(char *vslCode, int voyNo, int portCallSeq, int berthSeq, int seq, portcar_type *pret)
...
***Frtinv.hxx***
#pragma once
#include <voyage.ddh>
#include <vsched.ddh>
# ...
struct frtinvType : public frtinv_type
{
int fixCarSeq;
...
...
***frtinvxml.h***
#define _IN_MAIN_
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <zdb.hxx>
#include <opr32.h>
#include <voyage.ddh>
#include <frtinv.ddh> <------ Tried to add these two to the solution, that failed.
#include <frtinv.hxx> <------
void exitGracefully();
std::list<voyage_type> getVoyages();
있다 .. .
***frtinvxml.cpp***
#include "frtinvxml.h" <------ taking everything from frtinvxml.h
void main(int argc, char *argv[]) {
InitWinLib (10, 8);
...
내 문제는 fr 사실, 같은 폴더/솔루션에 파일을 놓을지라도 두 번 정의하지 않도록 할 수는 없습니다. 'pragma once'키워드를 사용하는 경우에도. 나는 또한 오래된 학교 #define을 사용하여 시도했다. 이미 존재한다면 ... 포함시키지 않는다. 그것은 역시 작동하지 않는다.
해결책이나 권장 사항이 있습니까?
감사합니다. 매우 도움이됩니다. C++로 실제로 작업 한 것은 이번이 처음입니다. (그리고 물론 작동 중입니다.) 이해해 주셔서 감사합니다. – Ian