6

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 dependent 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?

Community
  • 1
  • 1
mrkj
  • 3,041
  • 19
  • 24
  • 2
    As far as I know, it's impossible because VC++ is broken wrt to template instantiation. It just doesn't behave correctly (ie, is incorrect wrt to the standard) and thus mixing template and VC++ can be quite surprising. – Matthieu M. Nov 30 '10 at 15:59
  • I’m guessing the next best thing is having automated continuous builds on a server, e.g. via CDash. – Konrad Rudolph Nov 30 '10 at 16:02
  • This gets me every time I check code in to source control and the nightly linux build is run/ – John Dibling Nov 30 '10 at 16:05

2 Answers2

5

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!

Daniel Lidström
  • 9,930
  • 1
  • 27
  • 35
  • 11000 to 0 in a month ? How many of you worked at it !? I don't know TeamCity but I've heard of Cruise Control and Build Bot and I've personally worked with Hudson. There's plenty of frameworks around it seems. – Matthieu M. Dec 01 '10 at 07:34
  • @Matthieu: It took more than a month, more like two or even three. But we were 4 who worked together and maybe 2-3 others who helped now and then. The best part was when all were fixed. Then it became easy to see who was responsible for creating new. At that point any new warning from doxygen was treated as a hard error and everybody just had to fix them to make everything green in TeamCity :-D – Daniel Lidström Dec 01 '10 at 08:01
  • 1
    I agree, we've never had greener non-regressions tests that since we introduced Continuous Integration :) It's just amazing :) – Matthieu M. Dec 01 '10 at 08:40
0

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.

Suma
  • 33,181
  • 16
  • 123
  • 191
  • I did a bit more reading and it sounds like g++ prior to 3.3 might have been able to mimic the current vc++ behaviour. However, nowadays, it sounds like I'm outta luck. Thanks... – mrkj Dec 01 '10 at 22:26