diff --git a/CLAUDE.md b/CLAUDE.md index 912365a4..c14dd921 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -60,3 +60,21 @@ T default_value(); - Concise, dry answers - Full files, not diffs - Accurate, compiling C++ code + +## Symbol Visibility + +- Mark **all public classes with virtual functions or virtual base classes** with + `BOOST_HTTP_PROTO_SYMBOL_VISIBLE`. + + - This is required for: + - DSO (Dynamic Shared Object) builds compiled with hidden visibility. + - DLL builds with MinGW GCC due to its [non-conformance with MSVC](https://github.com/cppalliance/http_proto/issues/214). + +- Mark **all public exception types** and **public classes used as the operand of `dynamic_cast`** with + `BOOST_HTTP_PROTO_DECL`. + + - This ensures: + - RTTI (typeinfo) is exported from DLLs. + - RTTI is visible from DSOs. + - Once a class is marked with `BOOST_HTTP_PROTO_DECL`, **all of its member functions are exported automatically**. + - Do **not** mark the member functions individually. diff --git a/include/boost/http_proto/detail/config.hpp b/include/boost/http_proto/detail/config.hpp index 2a3f0ad3..a60d4a55 100644 --- a/include/boost/http_proto/detail/config.hpp +++ b/include/boost/http_proto/detail/config.hpp @@ -33,6 +33,12 @@ namespace http_proto { # define BOOST_HTTP_PROTO_DECL # endif +#if defined(__MINGW32__) + #define BOOST_HTTP_PROTO_SYMBOL_VISIBLE BOOST_HTTP_PROTO_DECL +#else + #define BOOST_HTTP_PROTO_SYMBOL_VISIBLE BOOST_SYMBOL_VISIBLE +#endif + # if !defined(BOOST_HTTP_PROTO_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_HTTP_PROTO_NO_LIB) # define BOOST_LIB_NAME boost_http_proto # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_HTTP_PROTO_DYN_LINK) diff --git a/include/boost/http_proto/impl/error.hpp b/include/boost/http_proto/impl/error.hpp index 75e107d8..a04362bd 100644 --- a/include/boost/http_proto/impl/error.hpp +++ b/include/boost/http_proto/impl/error.hpp @@ -41,7 +41,7 @@ namespace http_proto { namespace detail { -struct BOOST_SYMBOL_VISIBLE +struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE error_cat_type : system::error_category { @@ -58,7 +58,7 @@ struct BOOST_SYMBOL_VISIBLE } }; -struct BOOST_SYMBOL_VISIBLE +struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE condition_cat_type : system::error_category { diff --git a/include/boost/http_proto/server/route_handler.hpp b/include/boost/http_proto/server/route_handler.hpp index 399310d5..2db4e40a 100644 --- a/include/boost/http_proto/server/route_handler.hpp +++ b/include/boost/http_proto/server/route_handler.hpp @@ -34,7 +34,7 @@ struct acceptor_config /** Parameters object for HTTP route handlers */ -struct BOOST_SYMBOL_VISIBLE +struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE route_params : route_params_base { /** The complete request target @@ -180,7 +180,7 @@ post(F&& f) -> route_result if(task_) detail::throw_invalid_argument(); - struct BOOST_SYMBOL_VISIBLE + struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE immediate : detacher::owner { route_result rv; @@ -193,7 +193,7 @@ post(F&& f) -> route_result } }; - class BOOST_SYMBOL_VISIBLE model + class BOOST_HTTP_PROTO_SYMBOL_VISIBLE model : public task , public detacher::owner { diff --git a/include/boost/http_proto/server/router_types.hpp b/include/boost/http_proto/server/router_types.hpp index 39f2306f..0b16d9d4 100644 --- a/include/boost/http_proto/server/router_types.hpp +++ b/include/boost/http_proto/server/router_types.hpp @@ -36,7 +36,7 @@ using route_result = system::error_code; These values determine how the caller proceeds after invoking a route handler. Each enumerator represents a distinct control - action—whether the request was handled, should continue to the + action�whether the request was handled, should continue to the next route, transfers ownership of the session, or signals that the connection should be closed. */ @@ -111,7 +111,7 @@ struct is_error_code_enum< namespace http_proto { namespace detail { -struct BOOST_SYMBOL_VISIBLE route_cat_type +struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE route_cat_type : system::error_category { BOOST_HTTP_PROTO_DECL const char* name() const noexcept override; @@ -162,7 +162,7 @@ class detacher public: /** Base class of the implementation */ - struct BOOST_SYMBOL_VISIBLE + struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE owner { BOOST_HTTP_PROTO_DECL virtual resumer do_detach(); diff --git a/include/boost/http_proto/sink.hpp b/include/boost/http_proto/sink.hpp index 8445be7b..2e1ed88f 100644 --- a/include/boost/http_proto/sink.hpp +++ b/include/boost/http_proto/sink.hpp @@ -36,7 +36,7 @@ namespace http_proto { @ref source, @ref parser. */ -struct BOOST_HTTP_PROTO_DECL +struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE sink { /** The results of consuming data. @@ -188,6 +188,7 @@ struct BOOST_HTTP_PROTO_DECL @param more `true` if there will be one or more subsequent calls. */ + BOOST_HTTP_PROTO_DECL virtual results on_write( diff --git a/include/boost/http_proto/source.hpp b/include/boost/http_proto/source.hpp index 6be07b41..6e719f57 100644 --- a/include/boost/http_proto/source.hpp +++ b/include/boost/http_proto/source.hpp @@ -36,7 +36,7 @@ namespace http_proto { @ref sink, @ref serializer. */ -struct BOOST_HTTP_PROTO_DECL +struct BOOST_HTTP_PROTO_SYMBOL_VISIBLE source { /** The results of producing data. @@ -191,6 +191,7 @@ struct BOOST_HTTP_PROTO_DECL indicate failure or that no more data remains (or both). */ + BOOST_HTTP_PROTO_DECL virtual results on_read(