Can GCC create struct / class name mismatches like VS for example?

I would like GCC to issue a warning that VisualStudio generates when it finds a name that was declared with both class and struct . (Warning 4099) This usually occurs as a result of forward declarations, such as:

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

VS doesn't actually bind in this case, so I raised the warning to an error. Since this project is cross-platform, I would also like to find this problem when compiling with GCC - otherwise I may accidentally check code that will not work in VS.

Is there any switch or method to let the GCC also reject or warn of class / structure declaration inconsistencies?

NOTE. It is not clear from the comments whether this warning is legal. For my question, this does not matter, since the condition leads to a communication failure in VisualStudio (I cannot just ignore the warning). So, I just wanted to identify problems using GCC, so my Windows compilations don't stop working.


ANSWER: It seems that there is no solution.

+6
source share
2 answers

gcc doesn't care about the difference. Itanium ABI manages class and struct same way, leaving them as pure syntax difference.

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

+1
source

What version of VC ++ are you using. An error occurred in VC ++ 6.0, which meant that it handled struct and class differently, but was fixed in later compilers; For example, I do not see a warning with VC ++ 2005.

0
source

Source: https://habr.com/ru/post/886214/


All Articles