Skip to content

Commit ca0b7a8

Browse files
Copilotavikivity
andcommitted
Move all includes to global module fragment and add export namespace
Following the libstdc++ pattern more closely: - Moved all Seastar public headers to global module fragment (before 'export module') - Added 'export namespace seastar {}' to explicitly export the seastar namespace - This matches the libstdc++ approach of including all headers in the global fragment and then using export declarations to control what gets exported Co-authored-by: avikivity <[email protected]>
1 parent b571fc0 commit ca0b7a8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/seastar.cppm

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

2222
// C++20 module implementation for Seastar
2323
//
24-
// This file follows the libstdc++ approach where we import all headers
25-
// in the global module fragment and then re-export them as a module.
26-
// This avoids putting module declarations inside #ifdef blocks, which
27-
// is illegal per the C++ standard.
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.
2828

2929
module;
3030

31-
// Put all headers not provided by this module into the global module fragment
32-
// to prevent attachment to the module. These are dependency headers that
33-
// we use but don't re-export.
31+
// Put all headers into the global module fragment to prevent attachment
32+
// to the module. This includes both dependency headers and Seastar headers.
3433

3534
#include <any>
3635
#include <array>
@@ -141,11 +140,7 @@ module;
141140
#include <ucontext.h>
142141
#include <unistd.h>
143142

144-
export module seastar;
145-
146-
// Include all Seastar public headers to be exported in the module purview.
147-
// By including them after "export module", everything they declare in the
148-
// seastar namespace (and any std:: specializations) will be exported.
143+
// Include all Seastar public headers in the global module fragment
149144
#include <seastar/util/std-compat.hh>
150145
#include <seastar/core/abortable_fifo.hh>
151146
#include <seastar/core/abort_on_ebadf.hh>
@@ -298,6 +293,11 @@ export module seastar;
298293
#include <seastar/json/formatter.hh>
299294
#include <seastar/json/json_elements.hh>
300295

296+
export module seastar;
297+
298+
// Export the seastar namespace and all its symbols
299+
export namespace seastar {}
300+
301301
module : private;
302302

303303
// Include implementation headers in the private module partition.
@@ -335,4 +335,3 @@ module : private;
335335

336336
#include <seastar/http/url.hh>
337337
#include <seastar/http/internal/content_source.hh>
338-

0 commit comments

Comments
 (0)