Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.4.0 not building against VS9 (requires c++11 features) #3533

Closed
hajapy opened this issue Aug 21, 2017 · 6 comments
Closed

3.4.0 not building against VS9 (requires c++11 features) #3533

hajapy opened this issue Aug 21, 2017 · 6 comments

Comments

@hajapy
Copy link

hajapy commented Aug 21, 2017

Over at conda-forge we noticed that builds of protobuf 3.4.0 are failing with VS9 (see conda-forge/protobuf-feedstock#31) because of use of c++11 features. Here is the error:

C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(206) : error C2039: 'back' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>'
        with
        [
            _Elem=char,
            _Traits=std::char_traits<char>,
            _Ax=std::allocator<char>
        ]
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(212) : error C2039: 'unique_ptr' : is not a member of 'std'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(212) : error C2143: syntax error : missing ';' before '<'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(212) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(212) : error C2143: syntax error : missing ';' before '{'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(212) : error C2447: '{' : missing function header (old-style formal list?)
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(221) : error C2039: 'unique_ptr' : is not a member of 'std'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(221) : error C2059: syntax error : ']'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(222) : error C2065: 'wbuf' : undeclared identifier
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(222) : error C2228: left of '.get' must have class/struct/union
        type is ''unknown-type''
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(223) : error C2065: 'wbuf' : undeclared identifier
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(223) : error C2228: left of '.get' must have class/struct/union
        type is ''unknown-type''
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(327) : error C2039: 'unique_ptr' : is not a member of 'std'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(327) : error C2059: syntax error : ']'
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(328) : error C2065: 'wmode' : undeclared identifier
C:\bld\protobuf_1503290160041\work\protobuf-3.4.0\src\google\protobuf\stubs\io_win32.cc(328) : error C2228: left of '.get' must have class/struct/union
        type is ''unknown-type''
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

My understanding was that c++11 was only to be required as of 3.5 and on, so is this a bug in 3.4.0?

@liujisi liujisi self-assigned this Aug 21, 2017
@liujisi
Copy link
Contributor

liujisi commented Aug 21, 2017

Yes. I will send out a fix.

@liujisi
Copy link
Contributor

liujisi commented Aug 21, 2017

Could you try if this is fixed in 3.4.x branch?

@liujisi liujisi closed this as completed Aug 23, 2017
@jrandalldemllo
Copy link

jrandalldemllo commented Sep 27, 2017

The use of range-based for loop syntax (not supported until VS11) remains in io_win32.cc at 198
Attempts to build 3.4.1 against VS10 seems to fail with these errors:

"...\protobuf-3.4.1\build\debug\protobuf.sln" (default target) (1) ->
"...\protobuf-3.4.1\build\debug\ALL_BUILD.vcxproj.metaproj" (default target) (2) ->
"...\protobuf-3.4.1\build\debug\libprotobuf.vcxproj.metaproj" (default target) (6) ->
"...\protobuf-3.4.1\build\debug\libprotobuf.vcxproj" (default target) (7) ->
(ClCompile target) ->
  ..\..\protobuf-3.4.1\src\google\protobuf\stubs\io_win32.cc(198): error C2143: syntax error : missing ',' before ':' [...\protobuf-3.4.1\build\debug\libprotobuf.vcxproj]
  ..\..\protobuf-3.4.1\src\google\protobuf\stubs\io_win32.cc(198): error C2530: 's' : references must be initialized [...\protobuf-3.4.1\build\debug\libprotobuf.vcxproj]
  ..\..\protobuf-3.4.1\src\google\protobuf\stubs\io_win32.cc(198): error C3531: 's': a symbol whose type contains 'auto' must havean initializer [...\protobuf-3.4.1\build\debug\libprotobuf.vcxproj]
  ..\..\protobuf-3.4.1\src\google\protobuf\stubs\io_win32.cc(198): error C2143: syntax error : missing ';' before '{' [...\protobuf-3.4.1\build\debug\libprotobuf.vcxproj]

Otherwise the build will pass if the loop is changed to:

for (auto it = segments.begin(); it != segments.end(); ++it) {

@liujisi liujisi reopened this Sep 27, 2017
ybsave added a commit to ybsave/protobuf that referenced this issue Oct 18, 2017
Fix the same issue mentioned in protocolbuffers#3533
@jakirkham
Copy link

Still seeing some issues with VS9 when using the patch from PR ( #3769 ). Here's the build log.

@jakirkham
Copy link

jakirkham commented Nov 19, 2017

Namely it appears that auto and for-each are used here.

@jakirkham
Copy link

There’s also some calls to back on std::string instances. This method does not exist until C++11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants