Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can GCC produce struct/class name mismatches like VS?

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

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

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.

like image 742
edA-qa mort-ora-y Avatar asked Apr 19 '11 06:04

edA-qa mort-ora-y


1 Answers

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

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

like image 109
Matthieu M. Avatar answered Sep 16 '22 20:09

Matthieu M.