我试图激活该选项-Wmismatched-tags
在 gcc 上(检测不一致的类/结构声明,这可能在使用前向声明时发生),但在 Ubuntu 上我得到
c++: error: unrecognized command line option '-Wmismatched-tags'
我的海湾合作委员会版本:
# gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
看这里似乎它已集成在 gcc 4.9.0 中https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339
我是否做错了什么,或者该选项实际上不再可用?
我知道GCC 可以像 VS 一样产生结构/类名称不匹配吗? https://stackoverflow.com/questions/5712514/can-gcc-produce-struct-class-name-mismatches-like-vs,然而答案是 10 年前,我希望在此期间情况有所改善。
背景:我在一个项目中需要这个,我们也使用 clang 构建,并且这些不一致被视为错误。
看这里似乎它已集成在 gcc 4.9.0 中https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339
事实上,事实并非如此。这是 2014 年报道的,但正如 OP 中解释的那样#5号帖子 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61339#c5:
我不能代表 MS 发言,但我发布的原始警告已生成
叮当声。它does似乎担心标签不匹配。
In gcc -Wmismatched-tags
2019 年 12 月才推出,
成为 GCC 10 版本的一部分:
$ git describe e8f1ade269a39ea86a76a2440818e1512ed480ee
basepoints/gcc-10-5517-ge8f1ade269a
幸运的是,这些天我们有了 docker,官方 GCC 版本也发布了
正式发布为 docker 镜像:
$ docker search gcc
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
gcc The GNU Compiler Collection is a compiling s… 587 [OK]
(...)
所以你可以这样做:
docker run --rm -it gcc
并将源目录安装到 docker 容器中或
使用docker 的 TRAMP 集成
容器 https://github.com/emacs-pe/docker-tramp.el或任何其他
将代码放入容器并在其中使用最新的 gcc 的首选工具:
root@53d309d5d619:/# g++ --version
g++ (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@53d309d5d619:/# g++ hello.cpp -o hello -Wmismatched-tags
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)