How to use header units

Viewed 953

MSVC 2019, v16.8.1

I'm trying to start changing some existing code to use modules. My first attempt is to take an existing DLL, move all code into headers, except for one file which needs to be cpp so the compiler builds the dll (won't build with just headers).

I'm trying to follow this tutorial:

Practical C++20 Modules and the future of tooling around C++ Modules with Cameron DaCamara

My first try was changing one #import statement. Within the CPP file:

Changed:

#include "Some/Header.hpp"

To:

import "Some/Header.hpp";

I get this error:

error C7612: could not find header unit for '...../Some/Header.hpp'

I've tried all versions of the path to Some/Header.hpp, including absolute path, but the compiler just gives that same error.

Is there another step in the setup to instruct the compiler where to find headers? This is a CMake based project.


P.S. This modules feature seems, currently, very buggy. As soon as I started to use the import keyword, the IDE started to crash.


EDIT: NVM, this feature is definetly not fully cooked. Just tried changing another file to be modules, and it started to complain about some non-existing error. When I made a change to the code it was pointing to, just to experiment, I get this:

3>DevelopVision.ixx
3>..\..\..\Source\AppletGame\DevelopVision.ixx(323,1): fatal error C1001: Internal compiler error.
3>(compiler file 'msc1.cpp', line 1584)
3> To work around this problem, try simplifying or changing the program near the locations listed above.
3>If possible please provide a repro here: https://developercommunity.visualstudio.com
3>Please choose the Technical Support command on the Visual C++
3> Help menu, or open the Technical Support help file for more information
3>INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\CL.exe'

I'll give it a try in another year or so.

1 Answers
Related