0
votes

I have to compile program probcons but there are many errors. In readme autor writes program is compatible with gcc 4.3 but I have only 4.7.2. Is there any way to compile this old program? I don't believe that in program are errors because many bioinformatics servers are using it.

Most odd to me is this error:

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

In class SafeVector.h:

/////////////////////////////////////////////////////////////////
// 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

};

How it is possible that in older version of gcc wasn't need includes and std::prefix?

1
Try changing to std::size_t? size_t info - crashmstr
Usually it shouldn't be a problem to compile an older program with a newer version of GCC (the other way round would be harder). From your error it looks that size_t isn't known. For newer versions it should be std::size_t. You may try declaring a typedef for it. - πάντα ῥεῖ
Yes, all errors were due to missing includes or (like crashmstr wrote) missing std:: prefix. In older version there was no need to add std::?? How it could work in older version of gcc without std:: or includes? - Karlvonbahnhof
@Karlvonbahnhof You could also try to specify --std=c++03 as additional compiler option. IIRC gcc automatically tries to compile for c++11 standards. - πάντα ῥεῖ

1 Answers

1
votes

Try specifying the language standard for gcc. I suggest you try

-std=c++11

e.g g++ -std=c++11 -o out.exe myfile.cpp

first, I think it is most likely to compile it. If it doesn't work, try other choices.

How to add this depends on how the compilation is done, but one "quick&dirty" way is to add this is to find the makefile, find a line which specifies compiler flags variable CXXFLAGS and add that to it. Note: if it is a generated makefile, edits get overwritten if you run the generator again.