开发者

How can I get vc++ and g++ to behave the same regarding typename for dependent qualified types?

开发者 https://www.devze.com 2023-01-28 03:57 出处:网络
Is there a switch I can supply to cl.exe that will enable a warning or error when a typename is missing from a qualified de开发者_StackOverflow中文版pendent type?

Is there a switch I can supply to cl.exe that will enable a warning or error when a typename is missing from a qualified de开发者_StackOverflow中文版pendent type?

I'm working in an environment where developers tend to work one one platform, either Windows or Linux, and the code is ultimately built on both platforms nightly. We've encountered a problem with people forgetting to use typename on qualified dependent types on Windows, where Visual C++ 2008 will automatically insert a missing typename if possible. When they check in the code like this, it breaks the build on Linux, where g++ requires the typename. It would be desirable to tweak the Makefile such that we can expect the same typename behaviour on Windows and Linux to mitigate the likelihood of the build breaking. I prefer the g++ behaviour, but anything that would help the two platforms behave the same would be much appreciated.

See also Why do I need to use typedef typename in g++ but not VS?


My workplace solved all problems of this kind by introducing a continuous integration server. In our case we were quite satisfied with TeamCity. It is very customizable, and with some bash scripting I am sure you can present gcc errors nicely within TeamCity. I customized our server to the point where I was also getting Doxygen errors presented nicely and we reduced the number of errors from an initial 11000 to 0, over a couple of months.

Good luck!


There is no check like this in Visual Studio 2005 or 2008. The reason behind this is the compiler internals (the way templates are processed) are different between VS and GCC, and VS does much less processing until templates are instantiated. Pretty much everything seems to be explained in the question you have linked.

I think you may consider this a Visual Studio bug.

I am not sure what the status of this is in VS 2010 - I did not test it yet.

0

精彩评论

暂无评论...
验证码 换一张
取 消