Using '& gt; & gt; through gcc and visual c ++

advertisements

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


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.