gcc7fix8

Error when building FIX 8


Using gcc 7.1

[idf fix8]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-7/root/usr --mandir=/opt/rh/devtoolset-7/root/usr/share/man --infodir=/opt/rh/devtoolset-7/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --with-default-libstdcxx-abi=gcc4-compatible --with-isl=/builddir/build/BUILD/gcc-7.1.1-20170526/obj-x86_64-redhat-linux/isl-install --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.1.1 20170526 (Red Hat 7.1.1-2) (GCC) 
[idf fix8]$ 

when building FIX8 with this ./configure

[idf fix8]$ ./configure --with-mpmc=tbb --enable-tbbmalloc=yes --enable-f8test=no --enable-rawmsgsupport=yes --enable-doxygen=no --with-precision=single  --enable-preencode --enable-bufgloblogging=no  --enable-gtest=no

when I run make I get these errors (which is weird because I told it not to build tests!)

make  all-am
make[3]: Entering directory '/home/idf/Documents/c++/fix8/test'
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..    -I../include -g -O2 -Wall -MT libhftest_la-Perf_types.lo -MD -MP -MF .deps/libhftest_la-Perf_types.Tpo -c -o libhftest_la-Perf_types.lo `test -f 'Perf_types.cpp' || echo './'`Perf_types.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT libhftest_la-Perf_types.lo -MD -MP -MF .deps/libhftest_la-Perf_types.Tpo -c Perf_types.cpp  -fPIC -DPIC -o .libs/libhftest_la-Perf_types.o
In file included from Perf_types.cpp:77:0:
../include/fix8/logger.hpp:576:30: error: 'function' in namespace 'std' does not name a template type
 using logger_function = std::function<bool(const std::string&, Logger::Level, const char *, const unsigned)>;
                              ^~~~~~~~
../include/fix8/logger.hpp:580:2: error: 'logger_function' does not name a type; did you mean '__fortify_function'?
  logger_function _logger;
  ^~~~~~~~~~~~~~~

  etc...

I have confirmed that the build also fails with

gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)

I just verified that it does compile with

gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC) 

and it also does compile with

gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)

Please advise.


Solution

  • You have to explicitly #include <functional> in logger.hpp.

    The reason is stated in https://gcc.gnu.org/gcc-7/porting_to.html:

    Several C++ Standard Library headers have been changed to no longer include the header. As such, C++ programs that used components defined in without explicitly including that header will no longer compile.

    Previously components such as std::bind and std::function were implicitly defined after including unrelated headers such as < memory>, < future>, < mutex>, and < regex>. Correct code should #include < functional> to define them.