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

Fix gcc C++11 build #674

Closed
wants to merge 1 commit into from
Closed

Conversation

nsuke
Copy link
Contributor

@nsuke nsuke commented Aug 1, 2015

gcc with -std=c++11 failed because of conflicts between google/protobuf/stubs/mathutil.h and cmath.

cmake -GNinja -DCMAKE_CXX_FLAGS="-std=c++11 -DLANG_CXX11" ../cmake && ninja

[83/345] Building CXX object CMakeFiles/libprotobuf.dir/var/local/protobuf/src/google/protobuf/util/internal/utility.cc.o
FAILED: /usr/bin/c++   -DGOOGLE_PROTOBUF_CMAKE_BUILD -DHAVE_PTHREAD -DLIBPROTOBUF_EXPORTS -std=c++11 -DLANG_CXX11 -I. -I/var/local/protobuf/src -I/var/local/protobuf/gmock -I/var/local/protobuf/gmock/gtest -I/var/local/protobuf/gmock/gtest/include -I/var/local/protobuf/gmock/include -MMD -MT CMakeFiles/libprotobuf.dir/var/local/protobuf/src/google/protobuf/util/internal/utility.cc.o -MF "CMakeFiles/libprotobuf.dir/var/local/protobuf/src/google/protobuf/util/internal/utility.cc.o.d" -o CMakeFiles/libprotobuf.dir/var/local/protobuf/src/google/protobuf/util/internal/utility.cc.o -c /var/local/protobuf/src/google/protobuf/util/internal/utility.cc
In file included from /var/local/protobuf/src/google/protobuf/util/internal/utility.cc:44:0:
/var/local/protobuf/src/google/protobuf/stubs/mathlimits.h: In static member function 'static bool google::protobuf::MathLimits<double>::IsFinite(google::protobuf::MathLimits<double>::Type)':
/var/local/protobuf/src/google/protobuf/stubs/mathlimits.h:233:55: error: call of overloaded 'isinf(const Type&)' is ambiguous
   static bool IsFinite(const Type x) { return !isinf(x)  &&  !isnan(x); } \
...

(should be reproducible on plain ubuntu 14.04 with default gcc 4.8)

The incompatibility was already documented in the mathutil.h header comment and could be worked around by avoiding any direct or indirect cmath includes before mathutil.h.

liujisi added a commit to liujisi/protobuf that referenced this pull request Aug 25, 2015
…o beta-1

Manually merge pull request: protocolbuffers#674
that fixes the gcc C++11 build.
@liujisi
Copy link
Contributor

liujisi commented Aug 26, 2015

Manually merged into the beta-1 branch. Thanks for the fix!

@liujisi liujisi closed this Aug 26, 2015
bithium pushed a commit to bithium/protobuf that referenced this pull request Sep 4, 2023
…o beta-1

Manually merge pull request: protocolbuffers#674
that fixes the gcc C++11 build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants