1

使用 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]$ 

使用此 ./configure 构建 FIX8 时

[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

当我运行 make 我得到这些错误(这很奇怪,因为我告诉它不要构建测试!)

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

我已经确认构建也失败

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

我刚刚验证它确实可以编译

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

它也可以编译

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

请指教。

4

1 回答 1

4

你必须明确地#include <functional>logger.hpp中。

原因在https://gcc.gnu.org/gcc-7/porting_to.html中说明:

几个 C++ 标准库标头已更改为不再包含标头。因此,使用未明确包含该标头的组件的 C++ 程序将不再编译。

以前的组件(例如 std::bind 和 std::function)在包含不相关的标头(例如 <memory>、<future>、<mutex> 和 <regex>)后被隐式定义。正确的代码应该 #include <functional> 来定义它们。

于 2017-10-30T18:10:17.633 回答