rdmenezes / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Fix warning C4628 in MSVS2010 #151

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile chromium with /Wall with MSVC2010 SP1.

What is the expected output? What do you see instead?
...\src\testing\gmock\include\gmock/gmock-actions.h(116): warning C4628: 
digraphs not supported with -Ze. Character sequence '<:' not interpreted as 
alternate token for '['
is generated.
Ref: http://msdn.microsoft.com/en-us/library/5xk7ehw0.aspx

Which version of Google Mock are you using? On what operating system?
r403

Original issue reported on code.google.com by maruel@google.com on 29 Nov 2011 at 9:22

GoogleCodeExporter commented 9 years ago
The offending line is:

GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");

where the macro is defined as

#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
  template <> \
  class BuiltInDefaultValue<type> { \
   public: \
    static bool Exists() { return true; } \
    static type Get() { return value; } \
  }

The code conforms to the C++ standard and it is a bug in MSVC2010 SP1 that 
causes the warning.  It's wrong for the preprocessor to do the tokenization of 
'<type>' after substituting '::string' for 'type'.  However, we can easily work 
around the bug by changing

  <type>

to

  < type >

Original comment by w...@google.com on 29 Nov 2011 at 10:36

GoogleCodeExporter commented 9 years ago
Can someone take a look at http://codereview.appspot.com/5451043/ ?

I'd like to move on with that.

Original comment by maruel@google.com on 12 Dec 2011 at 7:28