2

我正在使用完整版的 VS2013,并试图将 atlbase 与 shelper 一起包含在一个类中,但我遇到了各种类型的错误。

我正在使用一个新生成的类,它将在没有这些包含的情况下干净地编译,并且其中几乎没有其他任何东西。

编译器正在查找库并似乎加载了它们,但是我得到了大约 20 个几乎就像这样的错误(我省略了其余的,但它们都和这些一样)

1>E:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atlcore.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:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atltransactionmanager.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:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atltransactionmanager.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:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atltransactionmanager.h(427): error C2039: 'DeleteFile' : is not a member of '`global namespace''
1>E:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atltransactionmanager.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:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atltransactionmanager.h(460): error C2039: 'MoveFile' : is not a member of '`global namespace''
1>E:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atltransactionmanager.h(487): warning C4191: 'type cast' : unsafe conversion from 'FARPROC' to 'PFNGETFILEATTRIBUTESTRANSACTED'
1>E:\Programs\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atlbase.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 Kits\8.1\include\um\sphelper.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 和/或 shelper.h 后才会出现。其中一半来自第一个,另一半来自第二个。

它们包括如下(在我的项目和类标题包含下):

#include <stdio.h>
#include <Windows.h>

#include "AllowWindowsPlatformTypes.h" 
#include <atlbase.h>
#include "sphelper.h"
#include "HideWindowsPlatformTypes.h"

我将它们放在这个“平台类型”块中,因为 atlbase 和 sphelper 库各自抛出大量错误,与任意声明或其他内容有关。

我没有以任何方式编辑库文件,并完全删除了所有库并从头开始重新安装。

这可能是由于我的疏忽或其他原因,但谁能解释为什么 atl 和 shelper 库不能正确包含?

编辑:

为了澄清,我“解决”导致此问题的问题的解决方案,我在“ https://answers.unrealengine.com/questions/27560/trouble-using-windows-includes-with-dword- int.html "

4

1 回答 1

2

我在一个更具体的网站上发布了我的问题,并在那里得到了答案。

用户 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 的充分信任。

于 2014-06-13T20:34:25.110 回答