Skip to content

Commit 300cb19

Browse files
Copilotavikivity
andcommitted
Include Seastar headers in module purview for automatic export
Changed from using 'export namespace seastar {}' to including Seastar headers in the module purview (after 'export module'). This automatically exports: - All symbols in the seastar namespace - std::hash specializations (marked with SEASTAR_MODULE_EXPORT in headers) Third-party headers (std, boost, system) remain in global module fragment and are NOT exported. This matches the intended behavior and avoids the need for explicit 'using' declarations for every symbol. Co-authored-by: avikivity <[email protected]>
1 parent ca0b7a8 commit 300cb19

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/seastar.cppm

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121

2222
// C++20 module implementation for Seastar
2323
//
24-
// This file follows the libstdc++ approach where all headers are included
25-
// in the global module fragment, and then we use export declarations to
26-
// re-export the seastar namespace as a module. This avoids putting module
27-
// declarations inside #ifdef blocks, which is illegal per the C++ standard.
24+
// This file follows the libstdc++ approach where third-party headers are
25+
// included in the global module fragment (and not exported), while Seastar
26+
// headers are included in the module purview (and automatically exported).
27+
// This avoids putting module declarations inside #ifdef blocks, which
28+
// is illegal per the C++ standard.
2829

2930
module;
3031

31-
// Put all headers into the global module fragment to prevent attachment
32-
// to the module. This includes both dependency headers and Seastar headers.
32+
// Put all third-party headers in the global module fragment to prevent
33+
// them from being attached to the module. Only Seastar headers will be
34+
// in the module purview and exported.
3335

3436
#include <any>
3537
#include <array>
@@ -140,7 +142,11 @@ module;
140142
#include <ucontext.h>
141143
#include <unistd.h>
142144

143-
// Include all Seastar public headers in the global module fragment
145+
export module seastar;
146+
147+
// Include all Seastar public headers in the module purview to export them.
148+
// This automatically exports everything declared in these headers, including
149+
// the seastar namespace and std::hash specializations.
144150
#include <seastar/util/std-compat.hh>
145151
#include <seastar/core/abortable_fifo.hh>
146152
#include <seastar/core/abort_on_ebadf.hh>
@@ -293,11 +299,6 @@ module;
293299
#include <seastar/json/formatter.hh>
294300
#include <seastar/json/json_elements.hh>
295301

296-
export module seastar;
297-
298-
// Export the seastar namespace and all its symbols
299-
export namespace seastar {}
300-
301302
module : private;
302303

303304
// Include implementation headers in the private module partition.

0 commit comments

Comments
 (0)