Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'inline' function definition for could not be written to module due to unrecognized expression or statement

I am experimenting with MSVC and modules.

I have the following code:

module;
#include "windows.h"
export module Module;

When I compile it in Win32 configuration I get the following:

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(1005,1): message : sorry: 'inline' function definition for 'ULONGLONG Int64ShllMod32(ULONGLONG,DWORD)' could not be written to module due to unrecognized expression or statement at 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(1010,5)'.
1>If possible please provide a repro here: https://developercommunity.visualstudio.com

The same happens for functions LONGLONG Int64ShraMod32(LONGLONG,DWORD) and ULONGLONG Int64ShrlMod32(ULONGLONG,DWORD).

The message does not show in x64 configuration.

So I would like to know:

  • Why the message comes out?
  • If it is safe to suppress it, how can I suppress it?

I am using Visual Studio 2022 version 17.5.0 (v143) and compiling with /std:c++20.

like image 742
Dundo Avatar asked Dec 05 '25 15:12

Dundo


1 Answers

I have encountered a similar accident to the problem you are having, so I am not sure if it will be helpful, but I will try to answer.

... In my case, it happened when I created the project using Visual Studio. According to that, the compiler may recognize the header file as a target for compilation. The proof is in the .vcproj included in the solution.

<ClCompile Include="srcfile.cpp" />

"srcfile.cpp" written in vcproj must contain only the source file. If a header file is included here, the compiler will compile it and look for 'inline' functions. Therefore, the following example is NG.

<ClCompile Include="srcfile.h" />

The header file needs to be rewritten as below and included in the nearby chunk.

<ClInclude Include="srcfile.h" />

My point may be wrong, or the problem in the title may be caused by another reason. Also, I'm Japanese and don't understand English very well. sorry.

like image 140
Nanase You Avatar answered Dec 09 '25 20:12

Nanase You



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!