microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.99k stars 1.65k forks source link

error while building with boost 1.66 #724

Open HumamHelfawi opened 6 years ago

HumamHelfawi commented 6 years ago

I am trying to build cpprestsk on Ubuntu 16.04 linking to Boost 1.66. I am getting this error:

error: conversion to ‘int’ from ‘ssize_t {aka long int}’ may alter its value [-Werror=conversion] int result = ::write(writedescriptor, &counter, sizeof(uint64_t));

The full log:

/home/humam/OtherSources/boost_1_66_0/boost/asio/detail/eventfd_select_interrupter.hpp:80:0, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/select_interrupter.hpp:25, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/epoll_reactor.hpp:28, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/reactor.hpp:21, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/scheduler.ipp:23, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/scheduler.hpp:212, from /home/humam/OtherSources/boost_1_66_0/boost/asio/system_context.hpp:19, from /home/humam/OtherSources/boost_1_66_0/boost/asio/impl/system_executor.hpp:22, from /home/humam/OtherSources/boost_1_66_0/boost/asio/system_executor.hpp:129, from /home/humam/OtherSources/boost_1_66_0/boost/asio/associated_executor.hpp:21, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/bind_handler.hpp:20, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/wrapped_handler.hpp:18, from /home/humam/OtherSources/boost_1_66_0/boost/asio/io_context.hpp:24, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/context.hpp:22, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl.hpp:18, from /home/humam/OptecksSources/cpprestsdk/Release/include/cpprest/http_client.h:53, from /home/humam/OptecksSources/cpprestsdk/Release/src/pch/stdafx.h:117, from /home/humam/OptecksSources/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp: In member function ‘void boost::asio::detail::eventfd_select_interrupter::interrupt()’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp:122:69: error: conversion to ‘int’ from ‘ssize_t {aka long int}’ may alter its value [-Werror=conversion] int result = ::write(writedescriptor, &counter, sizeof(uint64_t)); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp: In member function ‘bool boost::asio::detail::eventfd_select_interrupter::reset()’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp:135:75: error: conversion to ‘int’ from ‘ssize_t {aka long int}’ may alter its value [-Werror=conversion] int bytes_read = ::read(readdescriptor, &counter, sizeof(uint64_t)); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp:148:67: error: conversion to ‘int’ from ‘ssize_t {aka long int}’ may alter its value [-Werror=conversion] int bytes_read = ::read(readdescriptor, data, sizeof(data)); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/eventfd_select_interrupter.ipp:153:20: error: conversion to ‘int’ from ‘ssize_t {aka long int}’ may alter its value [-Werror=conversion] bytes_read = ::read(readdescriptor, data, sizeof(data)); ^ In file included from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/epoll_reactor.hpp:259:0, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/reactor.hpp:21, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/scheduler.ipp:23, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/scheduler.hpp:212, from /home/humam/OtherSources/boost_1_66_0/boost/asio/system_context.hpp:19, from /home/humam/OtherSources/boost_1_66_0/boost/asio/impl/system_executor.hpp:22, from /home/humam/OtherSources/boost_1_66_0/boost/asio/system_executor.hpp:129, from /home/humam/OtherSources/boost_1_66_0/boost/asio/associated_executor.hpp:21, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/bind_handler.hpp:20, from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/wrapped_handler.hpp:18, from /home/humam/OtherSources/boost_1_66_0/boost/asio/io_context.hpp:24, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/context.hpp:22, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl.hpp:18, from /home/humam/OptecksSources/cpprestsdk/Release/include/cpprest/http_client.h:53, from /home/humam/OptecksSources/cpprestsdk/Release/src/pch/stdafx.h:117, from /home/humam/OptecksSources/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/epoll_reactor.ipp: In member function ‘void boost::asio::detail::epoll_reactor::run(long int, boost::asio::detail::op_queue&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/epoll_reactor.ipp:461:13: error: conversion to ‘int’ from ‘long int’ may alter its value [-Werror=conversion] timeout = (usec < 0) ? -1 : ((usec - 1) / 1000 + 1); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/epoll_reactor.ipp: In member function ‘int boost::asio::detail::epoll_reactor::get_timeout(int)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/epoll_reactor.ipp:671:54: error: conversion to ‘int’ from ‘long int’ may alter its value [-Werror=conversion] (msec < 0 || max_msec < msec) ? max_msec : msec); ^ In file included from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/context.hpp:757:0, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl.hpp:18, from /home/humam/OptecksSources/cpprestsdk/Release/include/cpprest/http_client.h:53, from /home/humam/OptecksSources/cpprestsdk/Release/src/pch/stdafx.h:117, from /home/humam/OptecksSources/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/impl/context.ipp: In member function ‘boost::system::error_code boost::asio::ssl::context::use_certificate_chain(const boost::asio::const_buffer&, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/impl/context.ipp:740:12: error: conversion to ‘int’ from ‘long unsigned int’ may alter its value [-Werror=conversion] result = ::ERR_peek_last_error(); ^ In file included from /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/socket_ops.hpp:336:0, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ip/impl/address_v4.ipp:23, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ip/address_v4.hpp:328, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ip/address.hpp:24, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/impl/rfc2818_verification.ipp:22, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl/rfc2818_verification.hpp:93, from /home/humam/OtherSources/boost_1_66_0/boost/asio/ssl.hpp:21, from /home/humam/OptecksSources/cpprestsdk/Release/include/cpprest/http_client.h:53, from /home/humam/OptecksSources/cpprestsdk/Release/src/pch/stdafx.h:117, from /home/humam/OptecksSources/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp: In function ‘int boost::asio::detail::socket_ops::close(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:343:13: error: conversion to ‘boost::asio::detail::socket_ops::state_type {aka unsigned char}’ from ‘int’ may alter its value [-Werror=conversion] state &= ~non_blocking; ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp: In function ‘bool boost::asio::detail::socket_ops::set_user_non_blocking(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:395:13: error: conversion to ‘boost::asio::detail::socket_ops::state_type {aka unsigned char}’ from ‘int’ may alter its value [-Werror=conversion] state &= ~(user_set_non_blocking | internal_non_blocking); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp: In function ‘bool boost::asio::detail::socket_ops::set_internal_non_blocking(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, bool, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:444:13: error: conversion to ‘boost::asio::detail::socket_ops::state_type {aka unsigned char}’ from ‘int’ may alter its value [-Werror=conversion] state &= ~internal_non_blocking; ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp: In function ‘int boost::asio::detail::socket_ops::setsockopt(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, int, int, const void, std::size_t, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:1472:13: error: conversion to ‘boost::asio::detail::socket_ops::state_type {aka unsigned char}’ from ‘int’ may alter its value [-Werror=conversion] state &= ~enable_connection_aborted; ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp: In function ‘int boost::asio::detail::socket_ops::ioctl(boost::asio::detail::socket_type, boost::asio::detail::socket_ops::state_type&, int, boost::asio::detail::ioctl_arg_type, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:1753:15: error: conversion to ‘boost::asio::detail::socket_ops::state_type {aka unsigned char}’ from ‘int’ may alter its value [-Werror=conversion] state &= ~(user_set_non_blocking | internal_non_blocking); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp: In function ‘boost::system::error_code boost::asio::detail::socket_ops::getnameinfo(const socket_addr_type, std::size_t, char, std::size_t, char, std::size_t, int, boost::system::error_code&)’: /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:3459:79: error: conversion to ‘socklen_t {aka unsigned int}’ from ‘std::size_t {aka long unsigned int}’ may alter its value [-Werror=conversion] int error = ::getnameinfo(addr, addrlen, host, hostlen, serv, servlen, flags); ^ /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:3459:79: error: conversion to ‘socklen_t {aka unsigned int}’ from ‘std::size_t {aka long unsigned int}’ may alter its value [-Werror=conversion] /home/humam/OtherSources/boost_1_66_0/boost/asio/detail/impl/socket_ops.ipp:3459:79: error: conversion to ‘socklen_t {aka unsigned int}’ from ‘std::size_t {aka long unsigned int}’ may alter its value [-Werror=conversion] In file included from /home/humam/OtherSources/boost_1_66_0/boost/thread/thread_time.hpp:10:0, from /home/humam/OtherSources/boost_1_66_0/boost/thread/lock_types.hpp:18, from /home/humam/OtherSources/boost_1_66_0/boost/thread/pthread/mutex.hpp:16, from /home/humam/OtherSources/boost_1_66_0/boost/thread/mutex.hpp:16, from /home/humam/OptecksSources/cpprestsdk/Release/src/pch/stdafx.h:63, from /home/humam/OptecksSources/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/humam/OtherSources/boost_1_66_0/boost/date_time/microsec_time_clock.hpp: In instantiation of ‘static time_type boost::date_time::microsec_clock::create_time(boost::date_time::microsec_clock::time_converter) [with time_type = boost::posix_time::ptime; boost::date_time::microsec_clock::time_converter = tm ()(const long int, tm*); time_t = long int]’: /home/humam/OtherSources/boost_1_66_0/boost/date_time/microsec_time_clock.hpp:78:25: required from ‘static time_type boost::date_time::microsec_clock::universal_time() [with time_type = boost::posix_time::ptime]’ /home/humam/OtherSources/boost_1_66_0/boost/thread/thread_time.hpp:22:63: required from here /home/humam/OtherSources/boost_1_66_0/boost/date_time/microsec_time_clock.hpp:88:36: error: conversion to ‘uint32_t {aka unsigned int}’ from ‘__suseconds_t {aka long int}’ may alter its value [-Werror=conversion] boost::uint32_t sub_sec = tv.tv_usec; ^ In file included from /home/humam/OtherSources/boost_1_66_0/boost/date_time/adjust_functors.hpp:13:0, from /home/humam/OtherSources/boost_1_66_0/boost/date_time/gregorian/greg_duration_types.hpp:15, from /home/humam/OtherSources/boost_1_66_0/boost/date_time/gregorian/gregorian_types.hpp:22, from /home/humam/OtherSources/boost_1_66_0/boost/date_time/posix_time/posix_time_config.hpp:18, from /home/humam/OtherSources/boost_1_66_0/boost/date_time/posix_time/posix_time_system.hpp:13, from /home/humam/OtherSources/boost_1_66_0/boost/date_time/posix_time/ptime.hpp:12, from /home/humam/OtherSources/boost_1_66_0/boost/date_time/posix_time/posix_time_types.hpp:12, from /home/humam/OtherSources/boost_1_66_0/boost/thread/thread_time.hpp:11, from /home/humam/OtherSources/boost_1_66_0/boost/thread/lock_types.hpp:18, from /home/humam/OtherSources/boost_1_66_0/boost/thread/pthread/mutex.hpp:16, from /home/humam/OtherSources/boost_1_66_0/boost/thread/mutex.hpp:16, from /home/humam/OptecksSources/cpprestsdk/Release/src/pch/stdafx.h:63, from /home/humam/OptecksSources/cpprestsdk/Release/src/http/client/http_client.cpp:16: /home/humam/OtherSources/boost_1_66_0/boost/date_time/wrapping_int.hpp: In instantiation of ‘IntT boost::date_time::wrapping_int2<inttype, wrap_min, wrap_max>::calculate_wrap(IntT) [with IntT = int; inttype = short int; inttype wrap_min = 1; inttype wrap_max = 12]’: /home/humam/OtherSources/boost_1_66_0/boost/date_time/wrapping_int.hpp:126:26: required from ‘IntT boost::date_time::wrapping_int2<inttype, wrap_min, wrap_max>::add(IntT) [with IntT = int; inttype = short int; inttype wrap_min = 1; inttype wrap_max = 12]’ /home/humam/OtherSources/boost_1_66_0/boost/date_time/adjust_functors.hpp:76:118: required from ‘boost::date_time::month_functor::duration_type boost::date_time::month_functor::get_offset(const date_type&) const [with date_type = boost::gregorian::date; boost::date_time::month_functor::duration_type = boost::gregorian::date_duration]’ /home/humam/OtherSources/boost_1_66_0/boost/date_time/date_duration_types.hpp:67:49: required from ‘boost::date_time::months_duration::duration_type boost::date_time::months_duration::get_offset(const date_type&) const [with base_config = boost::gregorian::greg_durations_config; boost::date_time::months_duration::duration_type = boost::gregorian::date_duration; boost::date_time::months_duration::date_type = boost::gregorian::date]’ /home/humam/OtherSources/boost_1_66_0/boost/date_time/posix_time/date_duration_operators.hpp:33:37: required from here /home/humam/OtherSources/boost_1_66_0/boost/date_time/wrapping_int.hpp:151:14: error: conversion to ‘boost::date_time::wrapping_int2<short int, 1, 12>::inttype {aka short int}’ from ‘int’ may alter its value [-Werror=conversion] value -= (wrap_max - wrap_min + 1); ^ /home/humam/OtherSources/boost_1_66_0/boost/date_time/wrapping_int.hpp:156:14: error: conversion to ‘boost::date_time::wrapping_int2<short int, 1, 12>::inttype {aka short int}’ from ‘int’ may alter its value [-Werror=conversion] value += (wrap_max - wrap_min + 1); ^ cc1plus: all warnings being treated as errors src/CMakeFiles/cpprest.dir/build.make:62: recipe for target 'src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.o' failed make[2]: [src/CMakeFiles/cpprest.dir/http/client/http_client.cpp.o] Error 1 CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/cpprest.dir/all' failed make[1]: [src/CMakeFiles/cpprest.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: *** [all] Error 2

hyiyang commented 6 years ago

Met same issue with boost 1.65.1. Workaround by changing CMakeLists.txt: change -Werror to -Wno-error. Not sure if this workaround could be a problem in the future.

HumamHelfawi commented 6 years ago

@hyiyang yes that what did I do for compiling it. BTW, there is an CMake option for this if you do not you want to edit the flag manually.

Southclaws commented 6 years ago

there is an CMake option for this if you do not you want to edit the flag manually

What is that CMake option? I'm trying to set up a reproducable and automated build and I'd rather not mess about modifying the CMakeLists.txt file with janky scripts.

HumamHelfawi commented 6 years ago

@Southclaws it is WERROR. Just turn it off.|

zglozman commented 6 years ago

anybody worked this out ?

larsonmpdx commented 5 years ago

on the command line, pass "-DWERROR=OFF"

I don't think this is a cmake option, it's an option that cpprestsdk acts on. see https://github.com/Microsoft/cpprestsdk/blob/master/Release/src/CMakeLists.txt#L188

wintersteiger commented 5 years ago

+1 Similar errors on Ubuntu 18.04 with Boost 1.65.1.