Could I get some help with some problems with including atlbase in UE4?

Hey

I’m trying to include atlbase into a new ue4 project, but I get 2 different problems.

The first problem is that I get many errors telling me that various symbols are ambiguous, such as

ws2def.h(245): error C2872: 'INT' : ambiguous symbol

The only solution I found for this problem, was to put the libraries that are causing these problems in a block of allow/hide windows playform types, such as

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

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

This solves the first problem, but then causes this second main problem to take place.

The above inclusions are what I’m currently using, but they give me numerous errors such as the following (I omitted some because a lot of them are redundant):

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'

This then leads to my program failing to compile.

Does anyone know why this is happening? My aim is to include atlbase and sphelper as to gain access to the Windows Speech Recognition files, and everything was freshly installed and confirmed to work outside of UE4 based projects on the very same computer, using the same software.

I’m on Windows 7, 64 bit, running Visual Studio 2013 Ultimate.
,

We make use of atlbase.h in VisualStudioSourceCodeAccessor.cpp, but it seems we need to disable some warnings, and define some Windows functions in order to get it included without error.

The following should work:

#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"
1 Like

Hahaha, yes! That solves the problem.
Thank you so much!