Using local header files when packaging the plugin may result in an error

Hello, everyone.
I’ve recently been working on a plugin for serial communication, it works fine and can be run in a packaged game; however, when I make it a plugin, the pack plugin reports an error:

#include "CoreMinimal.h"
#include <process.h>    
#include "TChar.h"
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <cctype>
#include "Windows/MinWindows.h"  

------Functions that don’t apply to header files also report errors

 Building 2 actions with 20 processes...
UATHelper:    [1/2] Module.UESerialProt.cpp
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winnt.h(620): warning C4005: ??TEXT??: ???ض???
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\HAL/Platform.h(1085): note: ?μ???TEXT????ǰһ??????
UATHelper:    F:\Unreal\Pack\Plugins\UESerialProt\HostProject\Plugins\UESerialProt\Source\UESerialProt\Public\SerialProt.h(24): error C2143: ?﷨????: ȱ?١?;??(?ڡ?enum [tag]????ǰ??)
UATHelper:    F:\Unreal\Pack\Plugins\UESerialProt\HostProject\Plugins\UESerialProt\Source\UESerialProt\Public\SerialProt.h(25): error C4430: ȱ??????˵???? - ?ٶ?Ϊ int??ע??: C++ ??֧??Ĭ?? int
UATHelper:   F:\Unreal\Pack\Plugins\UESerialProt\HostProject\Plugins\UESerialProt\Source\UESerialProt\Public\SerialProt.h(36): error C2504: ??UObject??: δ????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformProcess.h(699): error C2062: ?????????͡?void??
UATHelper:    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\GenericPlatform/GenericPlatformProcess.h(700): error C2334: ??{????ǰ???????????ǣ????????Եĺ????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Containers/LockFreeList.h(214): error C2039: "_InterlockedCompareExchange": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper: ???????Եĺ????    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Containers/LockFreeList.h(214): error C2660: ??FIndexedPointer::_InterlockedCompareExchange??: ?????????? 3 ??????int    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Containers/LockFreeList.h(211): note: ?μ???FIndexedPointer::_InterlockedCompareExchang
e????????
UATHelper:    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1289): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper: rmMisc" ?ij?Ա    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1462): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:  indowsPlatformMisc" ?ij?Ա    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1469): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:  rmMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1471): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:  rmMisc" ?ij?Ա    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1489): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:  t.txt"
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1491): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:    D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1498): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Stats/Stats2.h(1505): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper: rmMisc" ?ij?Ա    D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectBase.h(190): error C2039: "_InterlockedCompareExchange": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectBase.h(190): error C2665: ??_InterlockedCompareExchange??: 4 ????????û??һ??????ת?????в???????
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9887): note: ?????ǡ?unsigned __int64 _InterlockedCompareExchange(volatile unsigned __int64 *,unsigned __int64,unsigned __int64)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9874): note: ??    ??unsigned long _InterlockedCompareExchange(volatile unsigned long *,unsigned long,unsigned long)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9863): note: ??    ??unsigned int _InterlockedCompareExchange(volatile unsigned int *,unsigned int,unsigned int)??
UATHelper:     D:\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\INCLUDE\intrin0.inl.h(149): note: ??    ??long _InterlockedCompareExchange(volatile long *,long,long)??
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectBase.h(190): note: ????ƥ???????б???(int32 *, int32, int32)??ʱ
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectBase.h(207): error C2039: "_InterlockedCompareExchange": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectBase.h(207): error C2665: ??_InterlockedCompareExchange??: 4 ????????û??һ??????ת?????в???????
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9887): note: ?????ǡ?unsigned __int64 _InterlockedCompareExchange(volatile unsigned __int64 *,unsigned __int64,unsigned __int64)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9874): note: ??    ??unsigned long _InterlockedCompareExchange(volatile unsigned long *,unsigned long,unsigned long)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9863): note: ??    ??unsigned int _InterlockedCompareExchange(volatile unsigned int *,unsigned int,unsigned int)??
UATHelper:     D:\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\INCLUDE\intrin0.inl.h(149): note: ??    ??long _InterlockedCompareExchange(volatile long *,long,long)??
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectBase.h(207): note: ????ƥ???????б???(int32 *, int32, int32)??ʱ
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(132): error C2039: "_InterlockedCompareExchange": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(132): error C2665: ??_InterlockedCompareExchange??: 4 ????????û??һ??????ת?????в???????
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9887): note: ?????ǡ?unsigned __int64 _InterlockedCompareExchange(volatile unsigned __int64 *,unsigned __int64,unsigned __int64)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9874): note: ??    ??unsigned long _InterlockedCompareExchange(volatile unsigned long *,unsigned long,unsigned long)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9863): note: ??    ??unsigned int _InterlockedCompareExchange(volatile unsigned int *,unsigned int,unsigned int)??
UATHelper:     D:\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\INCLUDE\intrin0.inl.h(149): note: ??    ??long _InterlockedCompareExchange(volatile long *,long,long)??
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(132): note: ????ƥ???????б???(int32 *, int32, int32)??ʱ
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(153): error C2039: "_InterlockedCompareExchange": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(153): error C2665: ??_InterlockedCompareExchange??: 4 ????????û??һ??????ת?????в???????
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9887): note: ?????ǡ?unsigned __int64 _InterlockedCompareExchange(volatile unsigned __int64 *,unsigned __int64,unsigned __int64)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9874): note: ??    ??unsigned long _InterlockedCompareExchange(volatile unsigned long *,unsigned long,unsigned long)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9863): note: ??    ??unsigned int _InterlockedCompareExchange(volatile unsigned int *,unsigned int,unsigned int)??
UATHelper:     D:\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\INCLUDE\intrin0.inl.h(149): note: ??    ??long _InterlockedCompareExchange(volatile long *,long,long)??
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(153): note: ????ƥ???????б???(int32 *, int32, int32)??ʱ
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(265): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(276): error C2039: "__faststorefence": ???? "FWindowsPlatformMisc" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformMisc.h(35): note: ?μ???FWindowsPlatformMisc????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\CoreUObject\Public\UObject/UObjectArray.h(392): error C2039: "_InterlockedCompareExchangePointer": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(35): error C2039: "_InterlockedIncrement": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(35): error C2665: ??_InterlockedIncrement??: 4 ????????û??һ??????ת?????в???????
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9720): note: ?????ǡ?unsigned __int64 _InterlockedIncrement(volatile unsigned __int64 *)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9708): note: ??    ??unsigned long _InterlockedIncrement(volatile unsigned long *)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9699): note: ??    ??unsigned int _InterlockedIncrement(volatile unsigned int *)??
UATHelper:     D:\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\INCLUDE\intrin0.inl.h(210): note: ??    ??long _InterlockedIncrement(volatile long *)??
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(35): note: ????ƥ???????б???(int32 *)??ʱ
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(47): error C2039: "_InterlockedDecrement": ???? "FWindowsPlatformAtomics" ?ij?Ա
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Windows/WindowsPlatformAtomics.h(13): note: ?μ???FWindowsPlatformAtomics????????
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(47): error C2665: ??_InterlockedDecrement??: 4 ????????û??һ??????ת?????в???????
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9752): note: ?????ǡ?unsigned __int64 _InterlockedDecrement(volatile unsigned __int64 *)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9740): note: ??    ??unsigned long _InterlockedDecrement(volatile unsigned long *)??
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(9731): note: ??    ??unsigned int _InterlockedDecrement(volatile unsigned int *)??
UATHelper:     D:\Microsoft\Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\INCLUDE\intrin0.inl.h(170): note: ??    ??long _InterlockedDecrement(volatile long *)??
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(47): note: ????ƥ???????б???(int32 *)??ʱ
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\Templates/RefCounting.h(47): error C2737: ??Refs??: ??????ʼ?? const ????
UATHelper: crement(volatile long *)??    [2/2] Module.UESerialProt.gen.cpp
UATHelper:     C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winnt.h(620): warning C4005: ??TEXT??: ???ض???
UATHelper:     D:\Epic Games\UE_4.27\Engine\Source\Runtime\Core\Public\HAL/Platform.h(1085): note: ?μ???TEXT????ǰһ??????
UATHelper: Took 13.4787156s to run UnrealBuildTool.exe, ExitCode=6
UATHelper: UnrealBuildTool failed. See log for more details. (C:\Users\Winseety-UE\AppData\Roaming\Unreal Engine\AutomationTool\Logs\D+Epic+Games+UE_4.27\UBT-UE4Game-Win64-Development.txt)
UATHelper: AutomationTool exiting with ExitCode=6 (6)
UATHelper: BUILD FAILED

I see that it is an error in compiling the “Module”, is there something I should add in the “.Build.cs” file?

Also I want to see all the modules supported in “PublicDependencyModuleNames.AddRange” how should I check? I didn’t find any information about this in the documentation or the forums.

I can provide all the code if needed.