简体   繁体   English

Visual Studio 编译器错误

[英]Visual studio compiler errors

I am making c++ dll in visual studio community 2019 but as I created project its shows me errors.我在 Visual Studio 社区 2019 中制作 c++ dll 但是当我创建项目时它向我显示错误。 default code for c++ dll c++ dll 的默认代码

// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

But visual studio gives these errors:但是视觉工作室给出了这些错误:

E1696   cannot open source file "windows.h"
E0020   identifier "BOOL" is undefined  
E0065   expected a ';'  4   

I have try messing with some settings which I seen on internet but that haven't helped.我尝试弄乱我在互联网上看到的一些设置,但没有帮助。

>>E1696 cannot open source file "windows.h" >>E1696 无法打开源文件“windows.h”

First of all you should check the physical existence of the file, it should be in "C:\Program Files (x86)\Windows Kits\10\Include" folder in your Visual Studio install directory.首先,您应该检查文件的物理存在,它应该位于 Visual Studio 安装目录的“C:\Program Files (x86)\Windows Kits\10\Include”文件夹中。

在此处输入图像描述

If the file exists, you should Go to Tools->Options and expand Projects and solutions.如果文件存在,您应该 Go 到 Tools->Options 并展开 Projects and Solutions。 Select VC++ Directories from the tree and choose Include Files from the combo on the right.You should see: Select 树中的 VC++ 目录,然后从右侧的组合中选择包含文件。您应该看到:

$(WindowsSDK_IncludePath); $(WindowsSDK_IncludePath);

在此处输入图像描述

If the file does not exist,you should download and install the Windows 10 SDK in the VS2019 installer.如果该文件不存在,您应该在 VS2019 安装程序中下载并安装 Windows 10 SDK。

在此处输入图像描述

The selected version needs to be the same as the version set in the project.选择的版本需要与项目中设置的版本一致。

在此处输入图像描述

>>E0020 identifier "BOOL" is undefined E0065 expected a ';' >>E0020 标识符“BOOL”未定义E0065 预期为 ';' 4 4

When you solve the first error, these error will also be solved.当您解决第一个错误时,这些错误也将得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM