1

I'm working on a project that uses the GNU common C++ class framework (1.8.1-7.el7). The project is written using C++98 (GCC 4.8.5) and I wanted to port it to C++11 or higher. When I compiled it using GCC 9.3.1, I get errors similar to the following:

[me@centos7 ~/github/myproject/utility2]$ make
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../include   -g -O2 -MT utility2.lo -MD -MP -MF .deps/utility2.Tpo -c -o utility2.lo utility2.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT utility2.lo -MD -MP -MF .deps/utility2.Tpo -c utility2.cpp  -fPIC -DPIC -o .libs/utility2.o
In file included from /usr/include/cc++/thread.h:50,
                 from ../include/myproject/utility1.h:4,
                 from ../include/myproject/utility2.h:6,
                 from utility2.cpp:1:
/usr/include/cc++/string.h:734:35: error: friend declaration of 'std::istream& getline(std::istream&, ost::String&, char, size_t)' specifies default arguments and isn't a definition [-fpermissive]
  734 |     friend __EXPORT std::istream &getline(std::istream &is, String &str, char delim = '\n', size_t size = 0);
      |                                   ^~~~~~~
make: *** [utility2.lo] Error 1

I read from here and here that it is impossible to selectively add -fpermissive to compile specific files (in this case, cc++/string.h from the GNU common C++ class framework) using modern GCC versions. I don't want to apply -fpermissive to all my files as that would not be good programming.

Is there a way to compile the GNU Common C++ class framework using C++11 or higher versions without having to broadly apply -fpermissive to all my files in the project? If so, how?

hermit.crab
  • 852
  • 1
  • 8
  • 20
  • 1
    please provide a [mre], what exactly are you trying to build? Is it the current version of common c++? – Alan Birtles Aug 02 '21 at 09:50
  • 1
    Should work as the Gentoo ebuild included some patches for c++14 and 17. Maybe you could look at those implementations. – akira hinoshiro Aug 02 '21 at 11:02
  • 1
    According to my experience, the best way to elevate such old sources to a more recent C++ version is to adopt the sources. But this is not an option in your case. So, there is no way AFAIK. – AD1170 Aug 02 '21 at 20:43

0 Answers0