GCC可以产生结构/类名称不匹配像VS? [英] Can GCC produce struct/class name mismatches like VS?

查看:107
本文介绍了GCC可以产生结构/类名称不匹配像VS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让GCC产生一个警告,VisualStudio产生,当它发现一个名称已声明与 class struct 。 (警告4099)这通常来自向前声明,如:

I would like to get GCC to produce a warning that VisualStudio produces when it finds a name that has been declared with both class and struct. (Warning 4099) This usually results from forward declarations such as:

struct Base;
...
class Base { ... };

在这种情况下,VS实际上无法链接,因此我将警告提升为错误。由于这个项目是跨平台的,我想在编译GCC时也发现这个问题 - 否则我可以不小心检查在VS中无法工作的代码。

VS actually fails to link in this case so I've promoted the warning to an error. Since this project is cross-platform I would like to also discover this issue when compiling with GCC -- otherwise I can accidentally check in code that won't work in VS.

有没有任何开关或方法,让GCC也拒绝或警告这样的类/ struct声明不匹配?

Is there any switch, or method, to get GCC to also reject, or warn, about such class/struct declaration mismatches?

注意:从评论中,不确定这个警告是否合法。对于我的问题,这是不相关的,因为条件导致在VisualStudio中的链接失败(我不能只是忽略警告)。因此,我只想确定使用GCC的问题,所以我的Windows编译不会突然停止工作。

NOTE: From the comments it is uncertain whether this warning is legitimate. For my question it isn't relevant since the condition causes the linking in VisualStudio to fail (I can't just ignore the warning). Thus I'd just like to identify the problems using GCC so my windows compiles don't suddenly stop working.

strong> ANSWER:似乎没有解决方案。

ANSWER: There appears to be no solution.

推荐答案

gcc不在乎区别。 Itanium ABI以相同的方式处理 class struct ,将它们作为纯粹的语法差异。

gcc does not care about the difference. The Itanium ABI mangles class and struct the same way, leaving them as pure syntactic difference.

Clang有 -Wmismatched-tags 可激活此检测,但找不到gcc等效项(如果有)。

Clang has -Wmismatched-tags to activate this detection, but I could not find the gcc equivalent (if any).

这篇关于GCC可以产生结构/类名称不匹配像VS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆