Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++20 modules: are path-relative imports a thing?

Tags:

c++

c++20

I know you can export modules like that in C++20:

export module modulename;

And import later as

import modulename;

But can you use filesystem paths in the module system somehow? Something like

import "./modulename.ixx"

I'm using MSVC 19.30.30528 (2022 preview).

like image 413
Alexey Pitenko Avatar asked Dec 07 '25 04:12

Alexey Pitenko


1 Answers

Module names are supposed to uniquely identify the module in question. So there are no provisions for specifying "ixx" or any other files. You say what the module name is, and your build system goes looking for modules matching that name. Period.

Importing a quoted string means that you are doing a header unit import. That means it will read the file in question much like you had done a #include and dump all of its symbols into your source file. The difference is that it effectively creates a module in so doing, such that if several files import the same header unit, the system doesn't need to recompile the header unit for each file that imports it.

like image 170
Nicol Bolas Avatar answered Dec 08 '25 16:12

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!