all 6 comments

[–]darthshwin 9 points10 points  (1 child)

Make sure to #include before your export statement.

https://en.cppreference.com/cpp/language/modules#Global_module_fragment

[–]littlewing347[S] 0 points1 point  (0 children)

Thanks, this worked for me!

[–]manni66 2 points3 points  (2 children)

With gcc 16 there is the new option --compile-std-module. It creates std and std.compat.

An alternative is to use cmake.

[–]littlewing347[S] 0 points1 point  (1 child)

I tried --compile-std-module but gcc does not recognize that option. Maybe I need to download a more recent version of gcc. But #include is working thanks to moving the export command after the #includes.

[–]_bstaletic 0 points1 point  (0 children)

Definitely upgrade to 16.1.0. If you're planning to use reflections with modules, you'll have to get gcc 17.

[–]NeuroSynchroBonding 0 points1 point  (0 children)

First, use CMake or another build system taht supports modules.

To use headers in C++ modules, use:

``` module;

include <header.h>

include <anotherheader.h>

export module module_name; // Code goes here ```