Steam_Callback() Error c2512 generated cpp

Hi, I am trying to create a function event that will fire when the Steam Game overlay is activated or deactivated,so I can pause the game play. However, I am trying to do the following, but it fails with the following error.

Error D:\Dropbox\MusicalRange-4.14\Intermediate\Build\Win64\UE4Editor\Inc\MusicalRange\MusicalRange.generated.cpp(608) : error C2512: ‘CCallback’: no appropriate default constructor available

Error D:\Dropbox\MusicalRange-4.14\Intermediate\Build\Win64\UE4Editor\Inc\MusicalRange\MusicalRange.generated.cpp(608) : note: see declaration of ‘CCallback’

Note that in the code I am skipping some functions that are not related to the problem.

#Header File

#include "ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h"
 #include "Engine/GameInstance.h"
 #include "MusicalRangeInstance.generated.h"

 UCLASS()
 class MUSICALRANGE_API UMusicalRangeInstance : public UGameInstance
  {
GENERATED_BODY()

 private:
STEAM_CALLBACK(UMusicalRangeInstance, OnSteamOverlayActive, GameOverlayActivated_t, m_callGameOverlayActive);

 public:

/*Constructor to be able to have STEAM_CALLBACKS build correctly*/
UMusicalRangeInstance();

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Steamworks")
bool IsSteamOverlayActive;

/*
* Must be called every frame so callbacks can be received
* Always Return True!
*/
UFUNCTION(BlueprintCallable, category = "Steamworks")
bool RunSteamCallbacks();

UFUNCTION(BlueprintImplementableEvent, Category = "Steamworks")
void OnSteamOverlayIsActive(bool isOverlayActive);

#CPP

 #include "MusicalRange.h"
 #include "MusicalRangeInstance.h"

 UMusicalRangeInstance::UMusicalRangeInstance(FVTableHelper& Helper)
: Super(Helper),
m_callGameOverlayActive(this, &UMusicalRangeInstance::OnSteamOverlayActive) {
 }

 bool UMusicalRangeInstance::InterLevelPersitentValuePONE() {
InterLevelPersitentValue++;
return true;
 }

 bool UMusicalRangeInstance::RunSteamCallbacks() {
SteamAPI_RunCallbacks();
return true;
  }

  void UMusicalRangeInstance::OnSteamOverlayActive(GameOverlayActivated_t *pParam) {
if (pParam->m_bActive != 0)
{
	IsSteamOverlayActive = true;
}
else
{
	IsSteamOverlayActive = false;
}
OnSteamOverlayIsActive(IsSteamOverlayActive);
return;
 }

I have looked at this other threads, where the generated file fails to compile the code when projects migrated from 4.7 to 4.8. I have tried a bunch of combinations but they all fail to compile, some with more errors than others. This set up is what yields the least errors, and is only at the generated cpp file.

Thanks.

UMusicalRangeInstance is declared empty in the header and with FVTableHelper& Helper arguments in the cpp file?

I don’t really understand our question.

As seen on the post, the header file has the constructor defined as

 /*Constructor to be able to have STEAM_CALLBACKS build correctly*/
 UMusicalRangeInstance();

and the cpp has the helper variable.

  UMusicalRangeInstance::UMusicalRangeInstance(FVTableHelper& Helper)
  : Super(Helper),
  m_callGameOverlayActive(this, &UMusicalRangeInstance::OnSteamOverlayActive) {

 }

Which is invalid. You need to remove FVTableHelper& Helper from the cpp.

So, it seems that STEAM_CALLBACK() macro clashes with UCLASS. So, I created in the same Header file another class, not a u class. And in the CPP file added the functions of the new class. The code does compile, but it crashes as soon as it’s run with Simulate Play.

The code had too many characters to add in, so I am using Pastebin.

Header File

The CPP File

The problem seems to be with UCLASS macro. STEAM_CALLBACK() conflicts, so it can’t compile properly. The way I managed around this was to create a second class to manage the callbacks. It compiles and the game doesn’t crash. But I still can’t get the callbacks to work.

1 Like