Hello
Thank you for your question and reaching out. I can understand you are having issues related to KMDF drivers.
To fix the error, first decide if you want Spectre mitigation. You can read about Spectre mitigation at the page for the /Qspectre compiler option. If you don't want Spectre mitigation, make sure it's disabled. For command-line builds, check that you're not using the /Qspectre compiler option or its variants /Qspectre-load and /Qspectre-load-cf. To disable it in the Visual Studio IDE, open Properties for your projects, and in the Configuration Properties > C/C++ > Code Generation property page, set the Spectre Mitigations property to Disabled
Reference :
https://learn.microsoft.com/en-us/visualstudio/msbuild/errors/msb8040?view=vs-2022
https://learn.microsoft.com/en-us/answers/questions/892052/driver-basic-steps-in-visual-studio.html
----------------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer--