2010-05-08 6 views
4

g ++에서 Windows C++ 프로그램을 컴파일하려고합니다. 이것이 내가 얻는 것입니다.g ++에서 Windows C++ 프로그램 컴파일

/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. 
btree.cpp:1204: error: ‘_TCHAR’ has not been declared 
btree.cpp: In function ‘int _tmain(int, int**)’: 
btree.cpp:1218: error: ‘__int64’ was not declared in this scope 
btree.cpp:1218: error: expected ‘;’ before ‘frequency’ 
btree.cpp:1220: error: ‘LARGE_INTEGER’ was not declared in this scope 
btree.cpp:1220: error: expected primary-expression before ‘)’ token 
btree.cpp:1220: error: ‘frequency’ was not declared in this scope 
btree.cpp:1220: error: ‘QueryPerformanceFrequency’ was not declared in this scope 
btree.cpp:1262: error: expected primary-expression before ‘)’ token 
btree.cpp:1262: error: ‘start’ was not declared in this scope 
btree.cpp:1262: error: ‘QueryPerformanceCounter’ was not declared in this scope 
btree.cpp:1264: error: name lookup of ‘i’ changed for ISO ‘for’ scoping 
btree.cpp:1264: note: (if you use ‘-fpermissive’ G++ will accept your code) 
btree.cpp:1304: error: expected primary-expression before ‘)’ token 
btree.cpp:1304: error: ‘end’ was not declared in this scope 
btree.cpp:1306: error: ‘total’ was not declared in this scope 
btree.cpp:1316: error: ‘getchar’ was not declared in this scope 

내가 처음으로 느낀 것은 아마도 윈도우 일 _TCHAR, _int64 및 LARGE_INTEGER 불리는 이러한 변수 유형이 있다는 것입니다. g ++에서 작동 할 수 있도록 이들을 어떻게 변경할 수 있습니까?

또한 여기에 g ++로 변환 할 수있는 항목이 있으면 도움이 될 것입니다.

는 여기에서 코드를 가지고 : http://touc.org/btree.html

+0

이미 windows.h를 제거했지만 이러한 문제는 해결되지 않았습니다. – neuromancer

답변

3

: 당신이 모두 _tmain 도랑 경우

// the main function is just some code to test the b-tree. it inserts 100,000 elements, 
    // then searches for each of them, then deletes them in reverse order (also tested in 
    // forward order) and searches for all 100,000 elements after each deletion to ensure that 
    // all remaining elements remain accessible. 

, 당신은 대부분 갈 수 있어야한다. __int64LARGE_INTEGER은 단지 QueryPerformanceCounter이 호출 될 수 있도록 사용되며 테스트 주 기능에서만 호출됩니다. 그것은 코드가 그렇지 않으면 상대적으로 이식성이있는 것처럼 보입니다. ++, 실제로 오류는 _tmain에서만 시작됩니다.

0

당신이 _TCHAR를 사용하는 경우, 당신은 또한 당신의 코드에서 다른 Windows - 특정 라이브러리를 사용하고 있습니다. 이미 QueryPerformanceCounter 및 QueryPerformanceFrequency (처음 사용한 두 가지 Windows 라이브러리 메서드, 실제로. =]) 유형을 변경하면 Windows libs 외부에서 일치하는 기능을 찾는 다음 단계로 넘어 가지 않습니다. 분명히 소스 파일은 수천 줄이 넘지 만 게시 할 수있는 이슈가 있습니까? 아니면 큰 프로젝트를 수행하려고합니까?

3

아마도 가장 간단한 대답은 winelib에 대한 것입니다.

가장 좋은 해결책은 더 많은 작업이 있지만 모든 창 특정 항목 주위에 #ifdef WIN32 개의 블록을 넣는 것입니다. 마찬가지로 동일한 기능을 구현하는 Linux는 #ifdef LINUX입니다. 이를 위해서는 많은 재구성 및 리팩토링이 필요할 수 있습니다.

0

내가 틀릴 수도 있지만 windows.h을 포함시키지 않아도 btree 또는 그와 비슷한 것을 만들 수 있습니다. 플랫폼 독립적 인 코드를 찾거나이 플랫폼 별 호출을 모두 QueryPerformanceCounter 등으로 제거하십시오.

또는 다른 좋은 템플릿 기반 B (또는 B +) 트리 구현을 얻으십시오. 그들 중 다수가 있습니다, 당신이 원한다면 나는 나의 것을 나눌 수 있습니다. 링크 된 페이지에서

+0

업로드 하시거나 링크를 보내 주시겠습니까? g ++로 작성된 B- 트리 소스 코드를 찾지 못했습니다. – neuromancer

관련 문제