0

I was doing a c++ homework which would be compiled with g++4.4.7, but I have some downgrade problem, so I decided to compile it with higher g++ version, but I don't know what library can be used in g++4.4.7, are there any document I can check?

By the way, can vector be included in g++ 4.4.7 ?

Oblivion
  • 7,176
  • 2
  • 14
  • 33
Steven
  • 811
  • 4
  • 23
  • 4
    Only by trying to compile it. You don't need to downgrade, you can install any version of gcc (or a dozen) alongside your system version. – n. m. could be an AI Jun 06 '19 at 15:53
  • It *shouldn't* really depend on compiler version, but on C++ standard that you use (`-std=` flag). Note that different compiler versions may have different default standard version, you may want to limit yourself to `c++03` if you are not sure what falgs are used at that `g++4.4.7` compiler – Yksisarvinen Jun 06 '19 at 15:56
  • 1
    One more note: `c++03` is the default option for g++ versions lower than 6.1, for 6.1 and up the default is `c++14` (or to be precise, the respective standard versions with GNU additions, so respectively `gnu++03` and `gnu++14`) – Yksisarvinen Jun 06 '19 at 16:05
  • 1
    It's more of a matter of what standard your class uses. If you need to compile against C++03 (no auto, smart pointers, variadic templates, ...) then you just need to make sure you specify `-std=c++03` when you compile. If not then you can use `-std=c++11` as gcc 4 started experimental support for C++11. More than likely the C++03 version is what your class requires. – NathanOliver Jun 06 '19 at 16:10
  • 4
    "By the way, can vector be included in g++ 4.4.7 ?" - `std::vector` has existed since C++98. Almost any compiler released since 1998 should support it just fine. – Jesper Juhl Jun 06 '19 at 16:29
  • Related: https://stackoverflow.com/questions/2324658/how-to-determine-the-version-of-the-c-standard-used-by-the-compiler – πάντα ῥεῖ Jun 06 '19 at 16:38

1 Answers1

1

Downgrading your compiler can be a mess. I wouldn't recommend it. I also wouldn't recommend teaching with such an outdated compiler.

Personally, I would go for one out of 2 approaches: install an old Linux version that comes with this Gcc version in a virtual machine or if it's a handful of files, use compiler explorer.

For virtualization, I only have experience with virtualbox, however other good alternatives exist. You search for a Linux distro that has that version of Gcc and install a temporary computer that way. Once the course is finished, you throw the machine out and your current system ain't affected.

The easier alternative is to simply plug your files in compiler explorer, it has a lot of different compiler versions including the compiler you need.

It does require you to enter file by file, so I would recommend writing a script to (recursively) resolve your local includes and create a simple preprocessed file that you can plug in the site.

For sure, write your code with a supported version of c++, don't use c++2a features when coding.

JVApen
  • 11,008
  • 5
  • 31
  • 67