Atlbase无法正确包含在虚幻引擎4中
Atlbase won't include properly in Unreal Engine 4
我正在使用VS2013的完整版本,并试图将atlbase包含到一个类中,以及sphelper,但我得到了各种类型的错误。
我正在使用一个新生成的类,它可以在没有这些包含的情况下干净地编译,并且里面几乎没有其他东西。
编译器正在寻找库并似乎加载它们,但随后我得到大约20个错误,这些错误都几乎就像这样(我省略了其余的,但它们都像这些错误)
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatlcore.h(630): warning C4191: 'reinterpret_cast' : unsafe conversion from 'FARPROC' to 'BOOL (__cdecl *)(DWORD)'
1> Calling this function through the result pointer may cause your program to fail
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatltransactionmanager.h(271): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'PFNCREATETRANSACTION'
1> Calling this function through the result pointer may cause your program to fail
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatltransactionmanager.h(321): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'PFNCOMMITTRANSACTION'
1> Calling this function through the result pointer may cause your program to fail
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatltransactionmanager.h(427): error C2039: 'DeleteFile' : is not a member of '`global namespace''
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatltransactionmanager.h(448): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'PFNMOVEFILETRANSACTED'
1> Calling this function through the result pointer may cause your program to fail
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatltransactionmanager.h(460): error C2039: 'MoveFile' : is not a member of '`global namespace''
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatltransactionmanager.h(487): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'PFNGETFILEATTRIBUTESTRANSACTED'
1>E:ProgramsMicrosoft Visual Studio 12.0VCATLMFCINCLUDEatlbase.h(5766): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'LSTATUS (__cdecl *)(HKEY,LPCWSTR,REGSAM,DWORD)'
1> Calling this function through the result pointer may cause your program to fail
1>C:Program Files (x86)Windows Kits8.1includeumsphelper.h(1333): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'LPFN_RegLoadMUIStringW'
1> Calling this function through the result pointer may cause your program to fail
这些错误只有在包含了atlbase.h和/或sphelper.h之后才会出现。一半来自第一组,另一半来自第二组。
它们包含如下(在我的项目和类头包含之下):
#include <stdio.h>
#include <Windows.h>
#include "AllowWindowsPlatformTypes.h"
#include <atlbase.h>
#include "sphelper.h"
#include "HideWindowsPlatformTypes.h"
我把它们放在这个"平台类型"块中,因为atlbase和sphelper库各自抛出了大量的错误,这些错误与任意声明或其他东西有关。
我没有以任何方式编辑库文件,并且完全删除了所有的库并从头重新安装。
这可能是由于我的疏忽或其他原因,但是有人能解释为什么atl和sphelper库不能正确包含吗?
编辑:澄清一下,我在"解决"导致这个问题的问题的解决方案,我在"https://answers.unrealengine.com/questions/27560/trouble-using-windows-includes-with-dword-int.html"
我在一个更具体的网站上发布了我的问题,并在那里得到了答案。
用户Jamie Dale在UE4 AnswerHub上发布了以下内容
#include "AllowWindowsPlatformTypes.h"
#pragma warning(push)
#pragma warning(disable: 4191) // warning C4191: 'type cast' : unsafe conversion
#pragma warning(disable: 4996) // error C4996: 'GetVersionEx': was declared deprecated
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
// atltransactionmanager.h doesn't use the W equivalent functions, use this workaround
#ifndef DeleteFile
#define DeleteFile DeleteFileW
#endif
#ifndef MoveFile
#define MoveFile MoveFileW
#endif
#include <atlbase.h>
#undef DeleteFile
#undef MoveFile
#include <sphelper.h>
#pragma warning(pop)
#include "HideWindowsPlatformTypes.h"
这个工作取代了我使用的包含,并完全解决了我遇到的所有问题。这是Jamie Dale的功劳
相关文章:
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 编译包含字符串的代码时遇到问题
- c++库的公共头文件中应该包含什么
- 将包含C样式数组的对象初始化为成员变量(C++)
- 是否需要删除包含对象的"pair"?
- 函数何时会在c++中包含stack_Unwind_Resume调用
- 如何将包含epoch时间的十六进制字符串转换为time_t
- 使用mongocxx驱动程序时包含头文件问题
- 如何在h文件中包含.o对象文件
- 在混合代码库中将C转换为C++时出现许多包含错误
- 当使用带有VS2019或VSCode的虚幻引擎4.24.2时,我如何修复这些错误的Intellisense错误
- VS2017,C++包含目录与附加包含目录,子文件夹包含失败-但为什么
- Unity在虚幻引擎4中的"Vector3.Slerp"等效C++?
- cmath抛出错误C2062、C2059、C2143和C2447.cmath包含在矢量文件中
- 如何将外部代码包含在虚幻引擎4 C++项目中
- C++ 在虚幻引擎中包含库后重新定义类型
- 虚幻引擎4.16,C++包含头文件
- Atlbase无法正确包含在虚幻引擎4中
- 如何使Visual Studio 2010不包含对MSVC运行时引擎的任何依赖项