Project compilation failed due to Microsoft SDK!

Brief description: Wow, Kaka, this time I caught Microsoft win10 ? , this time it also affected my writing code ? . Projects compiled with Release X86 will succeed, while switching to Release X64 will fail.

Error (active) E0147 declaration is incompatible with “BOOLEAN _BitScanForward” (declared at line 2825 of “C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winnt.h”) C:\ Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\intrin0.inl.h 123

Error C2007 #define syntax C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h 38
Error C2144 syntax error: ‘int’ should be preceded by ‘;’ C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h 43
Error C4430 missing type specifier – int assumed. Note: C++ does not support default-int C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h 43

[TOC]

This article was originally published on ” Xie Zang’s Small Station “, and is reproduced here simultaneously.

background

For commercial projects, it is always compiled in Release X86 mode, and optimization is turned off if debugging is required, and the entire solution can be compiled and passed. But this time, you need to compile an x64 dll for debugging; switch directly to Release X64 in the native VS 2019, and the error is as follows! ! ! ? win10 21H2 ? Qt 5.12.11 ? Visual Studio 2019

202205121649010.png

The X64 dll is clearly provided on JKS. Even if one line of the code is not changed, you still report so many errors? Are you serious! ! ! Beep loudly.

analyze

Mistakes are always read and solved from the very first, but this time, this one is very disappointing! ! !

So start looking at the mistakes at the bottom (yes, you are the point ? )

  • What’s wrong, syntax error? ? ?
  • Or is it a problem with Microsoft’s minwindef.h ? ? ? ? Are you sure it’s not our problem? ? ? (Do you believe your code is wrong, or do you believe Microsoft’s code is wrong???) Doubt in life ?

After checking the common basic settings (included header file path, library file link, C++ 17 and above, Unicode encoding, optimization off, multi-core compilation on), this error is still reported. After asking around, no one has compiled x64.

. . . Egg pain. . .

. . . Continue to be in pain. . .

. . . Continued pain in the egg. . .

Is it really Microsoft’s fault? ? ? , after thinking about it, look at this file again, combined with Compiler Error C2007 , and turn my attention to the minwindef.h file.

202205121705712.png

Ok? At this moment, I think the probability of the files in the file is 30%, but the probability that it may be your fault is 10%; go to the control center to find the Microsoft Visual Stdio Installer and upgrade the sdk separately (select the latest win10, not win11) ; Then recompile it, and it shows that it is successful. ?‍♂️? ,ecstasy

solve

The final solution was to upgrade the SDK from 10.0.19041.0 to 10.0.20348.0. hehe~

202205121732843.png

Afterwards, bc compared the two files, and it was real, and the mistake was obvious and rough. This is not a guess, and you can sleep peacefully at night. After all, the library provided by Microsoft is at fault.

202205131457931.png

Summarize

The biggest gain is this mental journey. I feel that the mighty Microsoft SDK cannot be wrong, it is only possible that there is a problem with our code. But this time, this “feudal superstition” in my heart has been broken, and after experiencing it myself, I know that nothing is impossible. This feeling is very wonderful. Broadly speaking, this is the third time I have encountered Microsoft’s error [1] , but the first two were not so obvious and direct.

series

QtExamples

welcome star ⭐ and fork ? This series of C++ / QT / DTK learning, with a directory of learning from shallow to deep.


[1] Notes, referring to:

This article is reproduced from: https://ifmet.cn/posts/38f2679b/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment