gcc警告"在GCC 7.1中为X传递的项目参数传递"是什么意思?

wog*_*gio 21 c++ gcc

我有一个C++项目,可以在x86 Linux和Windows上使用gcc 7.2进行构建,并且没有警告,我需要将它移植到ARM设备上,所以我尝试使用运行在我的"arm-linux-gnueabihf"gcc 7.2交叉编译它x86机器,它构建但我得到了很多这种警告

note: parameter passing for argument of type '__gnu_cxx::__normal_iterator<P2d*, std::vector<P2d> >' changed in GCC 7.1
_M_realloc_insert(end(), __x);
Run Code Online (Sandbox Code Playgroud)

/opt/armv7-gcc-2017/arm-linux-gnueabihf/include/c++/7.2.0/bits/vector.tcc:105:21: note: parameter passing for argument of type '__gnu_cxx::__normal_iterator<cpzparser::Anchor*, std::vector<cpzparser::Anchor> >' changed in GCC 7.1
    _M_realloc_insert(end(), std::forward<_Args>(__args)...);
Run Code Online (Sandbox Code Playgroud)

要么

/opt/armv7-gcc-2017/arm-linux-gnueabihf/include/c++/7.2.0/bits/vector.tcc:394:7: note: parameter passing for argument of type 'std::vector<cpzparser::PointEntity>::iterator {aka __gnu_cxx::__normal_iterator<cpzparser::PointEntity*, std::vector<cpzparser::PointEntity> >}' changed in GCC 7.1
       vector<_Tp, _Alloc>::
Run Code Online (Sandbox Code Playgroud)

生成的可执行文件似乎工作正常,但我担心所有这些警告的存在,因为我不知道他们的意思..任何线索?

Sne*_*tel 22

该警告告诉您在6和7.1之间存在一个微妙的ABI更改(实际上是一致性修复),因此当使用7.x构建的代码调用时,使用6.x或更早版本构建的库可能无法正常工作(并且反之亦然).只要您的所有C++代码都是使用GCC 7.1或更高版本构建的,您就可以安全地忽略此警告.要禁用它,请传递-Wno-psabi给编译器.

有关更改上下文的更多详细信息,请参阅GCC 7更改日志以及相关的错误.

  • 是否可以在系统范围的 GCC 配置中禁用此警告? (2认同)
  • @kyb 是的,您可以为此使用规范文件。但请不要。本地 GCC 的工作方式与其他人的 GCC 不同只是自找麻烦。相反,将该选项添加到您的 Makefile 或 CMakeLists.txt 或您用于构建程序的任何其他内容中。 (2认同)
  • @ValentinoZaffrani 您*不需要*更改任何内容,因为您的代码没有任何问题。您可以将有问题的函数参数更改为引用类型(更改仅影响按值传递的结构),但这将是愚蠢的。使用“-Wno-psabi”在命令行上禁用警告,或者按照[此 Q/A](/sf/ask/236499231/对于几行代码)。 (2认同)