开发者

Using '>>' across gcc and visual c++

We are writing an application that compiles with both gcc and Visual C++. Some team members only use Visual C++/Windows, and others only use gcc/linux. Due to differences between compilers the build sometimes breaks. I have "fixed" several scenarios that lead to build breaks using compiler options to enable/disable warnings, but currently I am stuck with the ">>" used within C++ templates.

Visual Studio seems to have unilaterally extended the standard to include ">>" as a valid expression within templates (this is valid only in the propos开发者_开发技巧ed C++0x). But gcc does not accept this as a valid template. Now I am unable to find an option in Visual Studio to disallow ">>" or in gcc to allow ">>". How should I proceed?

Note: This question is about the double angle bracket, not the right shift operator.


I would separate them to > >. That is what the current standards require; it is the most correct and portable code. As far as I'm aware, gcc won't even compile if the angle brackets are next to each other.


GCC currently (since version 4.3) supports this via:

g++ --std=c++0x -o output file1.cpp file2.cpp ...

You have to explicitly specify that your source code is written in C++0x standard.


The way to deal with such problems is to have Automatic Builds and Tests running around the clock, triggered by checkins. This is also referred to as Continuous Integration. When a build breaks or a test fails, you need to be able to lookup which checkin(s) lead to this and point a finger at the responsible developer(s).

See, for example, this answer for tools doing this across platforms.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜