Engine won't compile with Steamworks 1.32 (latest)

A new Steamworks SDK was released a few days ago, version 1.32 and after spending time trying to figure out why it wouldn’t compile. I determined that Steamworks now clobbers the ARRAY_COUNT macro from the UE.

// Unreal
#define ARRAY_COUNT( array ) (sizeof(ArrayCountHelper(array))+0)

// Steamworks 1.32
#define ARRAY_COUNT(COUNTER) CLANG_ATTR( "array_count:" #COUNTER ";" )

It can be easily worked around by not using the MACRO in the particular parts of the code that get broken., but is there something else that should really be done?

Hey Byte1-

Thanks for lettings us know about this problem. I have submitted this bug (UE-9453) to our internal database for further investigation.

Cheers

We’ll have to try an official integration with the new SDK to see how we can work around this. I’ve asked for a ticket to be filed to get this underway.

That being said, have you tried any bit of #undef ARRAY_COUNT to see if it can be circumvented? You could try in the Steam PCH that we have, right after we include steam_api.h?

I tried that a little bit ago and it was unsuccessful. It causes compilation errors in various engine files

Which engine files? The idea would be to add back the engine version of ARRAY_COUNT after the #undef. I’m assuming adding an include in our steam cpps. I don’t expect that we need their Steam version ever.

I just redid a new project to work on learning a bit about plugins, etc… so let me re-add the Steam SDK and I’ll post a followup!

I was able to fix this after more investigation. The undef/define did work, but I was missing the fact that SteamVR was also pulling the steam headers.

I submitted a pull request to make needed changes to the PCH headers for 4.7

edit: https://github.com/EpicGames/UnrealEngine/pull/819 (forgot to branch and had made some version changes that weren’t intended)

I fix SteamVRPrivatePCH.h and OnlineSubsystemSteamPrivatePCH.h, and recompie agan, still got error:
D:\Unreal Engine\UnrealEngine-4.7\Engine\Source\Runtime\Online\OnlineSubsystemSteam\Private\IPAddressSteam.cpp(21): error C2065: “array”: 未声明的标识符
1>D:\Unreal Engine\UnrealEngine-4.7\Engine\Source\Runtime\Online\OnlineSubsystemSteam\Private\OnlineIdentityInterfaceSteam.cpp(185): error C2065: “array”: 未声明的标识符
1>D:\Unreal Engine\UnrealEngine-4.7\Engine\Source\Runtime\Online\OnlineSubsystemSteam\Private\OnlineSessionAsyncServerSteam.cpp(949): error C2065: “array”: 未声明的标识符

Is their an official fix for this? It is biting us on an OS X Build currently.

The official fix is already checked in, and should be in 4.13, but I’ll post it here.

In OnlineSubsystemSteam\Source\Private\OnlineSubsystemSteamPrivatePCH.h

#pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT

#include "steam/steam_api.h"
#include "steam/steam_gameserver.h"

#pragma pop_macro("ARRAY_COUNT")

and
In \SteamController\Source\SteamController\Private\SteamControllerPrivatePCH.h

#pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT

#include <steam/steam_api.h>

#pragma pop_macro("ARRAY_COUNT")