简体   繁体   中英

C++20 modules - how to get their file names?

My aim is to build a simple c++ parser which collects the name of every struct / class in a c++ program.

The problem is concerning c++20 modules. Consider the following code:

import module-name;

How can my parser know where the module originated from and collect the name of structs /classes?

Had it been an #include directive my parser would just parse the given file name...

Is there any way to get the relevant file names for a given module?

The module files loaded by the compiler are all previously generated by the compiler. The compiler gives those files some name likely based on the module's given name. Exactly how that works is up to the compiler and build environment, and will likely vary among compilers.

Basically, it's not really your job. When you generate a module, you get some output files from the build system, just as you would a library or DLL. You then make those available to later builds that want to consume them, telling the compiler where it can find those module files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM