Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Symbol conflicts can occur when WebSocket++ headers are included in multiple shared libraries. The various
lib::error_category
singletons are particularly troublesome in this regard.For example, I recently ran into a bug in my code that was traceable to a comparison of error codes in
websocketpp::transport::asio::connection::handle_post_init_timeout()
.ec == transport::error::operation_aborted
invokeslib::error_code::operator==
, which first checks if the two operands' error categories are equal. In my case, they should have been, but thewebsocketpp::transport::error::category
singleton was included in two shared libraries, one of them having symbol visibility set to "hidden" by default. As the singleton symbol was not specifically exported from this library, it wasn't visible to the other library, and thus was not linked properly. This resulted in the address of one library's instance of the singleton being different than that of the other library's, and in the equality comparison returning the wrong result.In this pull request, I have explicitly exported
lib::error_category
singletons as well as exception classes (see Problems with C++ exceptions here) via the new_WEBSOCKETPP_EXPORT_SYMBOL
macro.My changes were made with WebSocket++'s focus on portability and minimizing dependencies in mind, but there may still be some concerns. I believe the decreased risk of symbol conflicts is worth it, but it is up to the maintainers in the end.
I ran the provided tests on my machine (Ubuntu 22.04, using GCC 12), and all went well. I additionally verified that the correct symbols were exported.