C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 编译错误:`’error_category’没有用g 6.3.0命名类型`大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试编译这个C / Pythonhttps://bitbucket.org/fluiddyn/fluidfft

如果安装了mpi4py,它运行良好.

如果未安装mpi4py,则无法编译不使用MPI的代码.

编译Cython文件时出现错误.错误很长,它开始于:

In file included from /usr/include/c++/6/bits/ios_base.h:46:0,from /usr/include/c++/6/ios:42,from /usr/include/c++/6/ostream:38,from /usr/include/c++/6/iostream:39,from src_cpp/base/base_fft.h:10,from fluidfft/fft2d/fft2d_with_fftw1d.cpp:543:
/usr/include/c++/6/system_error:143:31: error: ‘error_category’ does not name a type
     error_code(int __v,const error_category& __cat) noexcept
                               ^~~~~~~~~~~~~~
/usr/include/c++/6/system_error:152:27: error: ‘error_category’ does not name a type
     assign(int __v,const error_category& __cat) noexcept
                           ^~~~~~~~~~~~~~
/usr/include/c++/6/system_error:172:11: error: ‘error_category’ does not name a type
     const error_category&
           ^~~~~~~~~~~~~~
/usr/include/c++/6/system_error:191:11: error: ‘error_category’ does not name a type
     const error_category*  _M_cat;

[...]

我想这可能是一个C 11问题(http://en.cppreference.com/w/cpp/error/error_category),但我没有看到如何解决问题.

编译命令是

g++ -pthread -fwrapv -O3 -Wall -Wno-unused-result -Wsign-compare -Wno-unused-result -Wsign-compare -fwrapv -O3 -Wall -fPIC -I/home/users/me/opt/miniconda3/include/python3.6m -I/home/users/me/opt/miniconda3/include -Isrc_cy -Ifluidfft/fft2d -Ifluidfft/fft3d -Isrc_cpp/base -Isrc_cpp/3d -Isrc_cpp/2d -Iinclude -I/home/users/me/opt/miniconda3/lib/python3.6/site-packages/numpy/core/include -c fluidfft/fft2d/fft2d_with_fftw1d.cpp -o build/temp.linux-x86_64-3.6/fluidfft/fft2d/fft2d_with_fftw1d.o

编辑最小,完整和可验证的示例

感谢Ashwin Vishnu(见https://bitbucket.org/fluiddyn/fluidfft/issues/7/fluidfft-installation-fails-without-mpi4py),我可以发布一个最小的例子

/* test.cpp */
#include <Python.h>
#include <String.h>
#include <stdio.h>

#include <cpu.h>

#include <sys/time.h>
#include <complex>
#include <iostream>


int main() {
  std::cout<<"Hello world";
  return 0;
}

从fluidfft目录编译如下:

g++ $(python-config --includE) -Iinclude/ test.cpp

如果我们注释掉cpu.h include,就没有错误.

文件cpu.h取自pyfftw代码https://github.com/pyFFTW/pyFFTW/blob/master/include/cpu.h

解决方法

发生这种情况是因为包flowfft的Cython源文件依赖于 a C++ header file cpu.h,其中以下预处理器行导致了问题:

#if __STDC_VERSION__ >= 199901L
  /* "inline" is a keyword */
#else
# define inline
#endif

我的猜测是新编译器严格重新定义保留关键字.根据essay on inline functions提示,这段代码被替换为:

#if __STDC_VERSION__ >= 199901L
  /* "inline" is a keyword */
#else
# define INLINE
#endif

#ifndef INLINE
# if __GNUC__ && !__GNUC_STDC_INLINE__
#  define INLINE static inline
# else
#  define INLINE inline
# endif
#endif

大佬总结

以上是大佬教程为你收集整理的c – 编译错误:`’error_category’没有用g 6.3.0命名类型`全部内容,希望文章能够帮你解决c – 编译错误:`’error_category’没有用g 6.3.0命名类型`所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。