2013-11-26 2 views
0

프로그램 probcons을 컴파일해야하지만 많은 오류가 있습니다. readme autor 쓰기 프로그램은 gcc 4.3과 호환되지만 4.7.2 만 있습니다. 이 오래된 프로그램을 컴파일 할 방법이 있습니까? 나는 많은 생물 정보학 서버가 그것을 사용하고 있기 때문에 프로그램에서 오류라고 생각하지 않는다.구식 gcc 용 프로그램 컴파일

나에게 가장 이상한

이 오류입니다 : 클래스 SafeVector.h에서

Description     Resource   Path  Location Type 

expected ‘)’ before ‘size’ SafeVector.h /probcons line 27 C/C++ Problem 
expected ‘)’ before ‘size’ SafeVector.h /probcons line 26 C/C++ Problem 

: GCC의 이전 버전에서 필요하지 않은 가능성이 얼마나

///////////////////////////////////////////////////////////////// 
// SafeVector.h 
// 
// STL vector with array bounds checking. To enable bounds 
// checking, #define ENABLE_CHECKS. 
///////////////////////////////////////////////////////////////// 

#ifndef SAFEVECTOR_H 
#define SAFEVECTOR_H 

#include <cassert> 
#include <vector> 

///////////////////////////////////////////////////////////////// 
// SafeVector 
// 
// Class derived from the STL std::vector for bounds checking. 
///////////////////////////////////////////////////////////////// 

template<class TYPE> 
class SafeVector : public std::vector<TYPE>{ 
public: 

    // miscellaneous constructors 
    SafeVector() : std::vector<TYPE>() {} 
    /*ERROR HERE*/ SafeVector(size_t size) : std::vector<TYPE>(size) {} 
    /*ERROR HERE*/ SafeVector(size_t size, const TYPE &value) : std::vector<TYPE>(size, value) {} 
    SafeVector(const SafeVector &source) : std::vector<TYPE>(source) {} 

#ifdef ENABLE_CHECKS 

    // [] array bounds checking 
    TYPE &operator[](int index){ 
    assert (index >= 0 && index < (int) size()); 
    return std::vector<TYPE>::operator[] ((size_t) index); 
    } 

    // [] const array bounds checking 
    const TYPE &operator[] (int index) const { 
    assert (index >= 0 && index < (int) size()); 
    return std::vector<TYPE>::operator[] ((size_t) index) ; 
    } 

#endif 

}; 

포함 및 표준 : :접두사?

+6

'std :: size_t'로 변경해보십시오. [size_t info] (http://en.cppreference.com/w/cpp/types/size_t) – crashmstr

+0

보통 새 버전의 GCC로 이전 프로그램을 컴파일하는 데 문제가 없어야합니다 (다른 방법은 더 열심히). 오류에서 'size_t'을 알 수 없습니다. 새로운 버전의 경우에는'std :: size_t'이어야합니다. 당신은 그것을위한 typedef를 선언 할 수 있습니다. –

+0

예, 모든 오류는 include 또는 (crashmstr wrote) std :: prefix가 누락 되었기 때문에 발생했습니다. 이전 버전에서는 std :: ??를 추가 할 필요가 없었습니다. gcc의 이전 버전에서 std ::없이 또는 어떻게 작동합니까? – Karlvonbahnhof

답변

0

gcc에 대해 specifying the language standard을 시도하십시오. 추천 해 드리겠습니다.

-std=g++11 

먼저 컴파일하는 것이 좋습니다. 작동하지 않으면 다른 선택 사항을 시도하십시오.

어떻게 추가 할 것인가는 컴파일의 방법에 달려 있지만, "& dirty"는 makefile을 찾고 컴파일러 플래그 변수 CXXFLAGS을 지정하고 추가하는 것입니다. 참고 : 생성 된 makefile 인 경우 생성기를 다시 실행하면 편집 내용을 덮어 씁니다.

+0

불행히도, 모든 -std = C++ 가능성을 시도했지만 아무것도 작동하지 않습니다. std :: prefix와 some #include 만 추가하십시오. – Karlvonbahnhof