Closed tgill880 closed 5 years ago
Please try CXXFLAGS += instead of =. You are removing -mlongcalls and other flags which are added by the build system to the default CXXFLAGS.
Yes, that fixed the problem. I also needed to enable exceptions.
CXXFLAGS += -std=c++17 -fexceptions
Many thanks!
For enabling exceptions, please use a menuconfig option (under compiler config).
Aside from adding -fexceptions to CXXFLAGS, it enabled the required run-time support for exception handling in the early start up code. Without that, any exception thrown will lead to abort. See examples/system/cpp_exceptions.
Exceptions now enabled in menuconfig
. Thanks.
I have now added all the application code to be ported to the chops-net-ip
version of chat_server
. A new compiler error is present.
In file included from /home/thurman/esp/esp-idf/components/asio/asio/asio/include/asio/ip/basic_endpoint.hpp:20,
from /home/thurman/esp/esp-idf/components/asio/asio/asio/include/asio/ip/tcp.hpp:24,
from /home/thurman/Projects/ESP32/chops_chat_server/components/chops-net-ip/include/net_ip/net_ip.hpp:30,
from /home/thurman/Projects/ESP32/chops_chat_server/main/chat_server.cpp:42:
/home/thurman/esp/esp-idf/components/asio/asio/asio/include/asio/ip/detail/endpoint.hpp: In member function 'bool chops::net::detail::io_common<IOT>::start_write_setup(const chops::const_shared_buffer&) [with IOT = chops::net::detail::tcp_io]':
/home/thurman/esp/esp-idf/components/asio/asio/asio/include/asio/ip/detail/endpoint.hpp:47:24: error: '<anonymous>.asio::ip::detail::endpoint::data_' may be used uninitialized in this function [-Werror=maybe-uninitialized]
: data_(other.data_)
^
cc1plus: some warnings being treated as errors
/home/thurman/esp/esp-idf/make/component_wrapper.mk:289: recipe for target 'chat_server.o' failed
make[1]: *** [chat_server.o] Error 1
/home/thurman/esp/esp-idf/make/project.mk:582: recipe for target 'component-main-build' failed
make: *** [component-main-build] Error 2
This error is triggered by the copy constructor of the asio
endpoint
helper class.
From: /home/thurman/esp/esp-idf/components/asio/asio/asio/include/asio/ip/detail/endpoint.hpp
// Copy constructor.
endpoint(const endpoint& other)
: data_(other.data_)
{
}
In my code, an endpoint
is used in a lambda callback:
using io_interface = chops::net::tcp_io_interface;
using const_buf = asio::const_buffer;
using endpoint = asio::ip::tcp::endpoint;
// receive text from client, send out to others
const auto msg_hndlr = [](const_buf buf, io_interface iof, endpoint ep) {
// code not listed
}
Of course, this code compiles fine with the latest g++ and clang++ on linux, macOS and Windows environments.
My various lame attempts to override the -Werror=maybe-uninitialized
flag have failed:
CXXFLAGS += -std=c++17 -Wno-error
CXXFLAGS := $(filter-out -Werrorr=maybe-uninitialized,$(CXXFLAGS))
CXXFLAGS := $(filter-out -Werror,$(CXXFLAGS))
In menuconfig
:
[*] Disable new warnings introduced in GCC 6 - 8
Your prompt responses are greatly appreciated.
Hi @tgill880
Do you have to add https://github.com/connectivecpp/chops-net-ip to reproduce this build failure? It looks like simply compiling asio/using endpoints works under c++17.
Meantime, it might be possible to ignore the maybe-uininialized
error with
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
``` in the code.
Yes.
The #pragma
suppresses the warning, and the code compiles and is uploaded to the ESP32.
Many thanks.
On further testing, it is clear that chops-net-ip
and asio
are not working well together in this enviromment. Since the build failure has been solved, I will close this ticket and open another if needed.
Environment
Problem Description
C++17 build failure when compiling C++17 header only network library that relies on
asio
.I am attempting to port an open source, C++17 networking library, chops-net-ip, to the
ESP32
. The library builds on top ofasio
. I can get theasio
sample apps to run correctly on my development board. I am using theasio
chat_server
project as starter code (to get the right headers forasio
). When I add thechops-net-ip
headers, I get a thicket of build errors, and the build fails.C++17 is only used for the project source file.
component.mk
(in main)Expected Behavior
Project builds.
Actual Behavior
Project does not build.
Steps to reproduce
See above
Code to reproduce this issue
Debug Logs
Compiler output
Other items if possible
sdkconfig file: