Resharper C++ 20 module support wants to add forward declaration

I have created a project from the Named modules tutorial C++  using the steps in the web-site using vs2022 17.4.3 and Resharper c++ 2022.3.1

The project compiles and runs correctly.

However, Resharper incorrectly suggest in the module unit implementation file - BasicPlane.Figures-Rectangle.cpp - that a forward declaration for Rectangle is required, highlights the class name and provides a popup to make the fix. However, the fix is unnecessary. See the image below:

If the fix is applied, then further errors are indicated (Type Rectangle is incomplete). See below:

I have been able to turn off the fix popup but not remove the red highlighting. Is there some way of turning off the fix suggestion altogether? Is there any other work around?

0
5 comments

Hello,

Could you please send us your project for investigation? You can upload it to https://uploads.jetbrains.com/, let us know the upload id.

Thanks!

0

Done.

Upload ID: 2023_01_02_2cLp6sA4dzXFKTKW26DGvk

 

0

Thanks!

I believe both the MSVC compiler and the tutorial are incorrect and that you need "import :Rectangle;" in BasicPlane.Figures-Rectangle.cpp to make the code conforming to the standard. 

I've filed an issue with MS with my reasoning - https://developercommunity.visualstudio.com/t/%D0%A120-modules:-a-partition-implementatio/10243503, take a look if you're interested in details.

0

One more note. According to the C++ standard (https://eel.is/c++draft/module#unit-3), it looks like a single module partition cannot be defined in multiple module units, e.g. a .cpp and an. ixx files:

module partition is a module unit whose module-declaration contains a module-partition. A named module shall not contain multiple module partitions with the same module-partition.
 
So this means that the BasicPlane.Figures:Rectangle partition cannot be split over two files in conformant code, and the tutorial is somewhat misleading.
0

Thanks for the feedback

0

Please sign in to leave a comment.