简体   繁体   中英

Visual studio compiler errors

I am making c++ dll in visual studio community 2019 but as I created project its shows me errors. default code for 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"

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.

在此处输入图像描述

If the file exists, you should Go to Tools->Options and expand Projects and solutions. Select VC++ Directories from the tree and choose Include Files from the combo on the right.You should see:

$(WindowsSDK_IncludePath);

在此处输入图像描述

If the file does not exist,you should download and install the Windows 10 SDK in the VS2019 installer.

在此处输入图像描述

The selected version needs to be the same as the version set in the project.

在此处输入图像描述

>>E0020 identifier "BOOL" is undefined E0065 expected a ';' 4

When you solve the first error, these error will also be solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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