Does declaring delegates require a (dummy) class?

The context

I want to outsource dome delegate declarations to a different header file and include this file any other header file, where I need to use the delegate. But it does not compile saying the delegate is an unknown/unrecognized type. Currently, I need to add a dummy UCLASS to this delegates header file and a .generated.h include statement to make it work.

How to reproduce the compiler error

Create a file Delegates.h with the following content:

#include "UObject/ScriptDelegates.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSomeDelegateSignature, int32, integer);

Include this file and use it in another class by adding the following property:

UPROPERTY(BlueprintAssignable, Category="Unreal")
      FSomeDelegateSignature OnCreateAwesomeGameButtonPressed;

My current hotfix

Change the Delegates.h content as follows:

#include "Object.h"
#include "Delegates.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSomeDelegateSignature, int32, integer);

UCLASS()
	class MYPROJECT_API UDelegates : public UObject
{
	GENERATED_BODY()
};

My issue

I don’t want to create a new class. And I heard that you dont need to (and that there are examples inside the engine code that proves this). So what am I doing wrong?

push…

What if you don’t create the UCLASS but leave the Delegates.generated.h include?

I already tried that, but that didnt work. I think it regenerates the Delegates.generated.h when I hit build. And when there is no UCLASS, it does not generate the necessary classes anymore

Did you ever figure this out? I’m trying to do the same thing now and don’t want a dummy class…

Hmm no, actually not. For now, I am putting stuff like this into a class which will generate reflection code anyway and for that, I choose my “Statics” class (the code where I put all my globally accessible, static functions and variables)…

There is an example of how to do such thing in CoreDelegates.h.

Keep in mind tho, that delegates declared like that won’t be visible in blueprints.

Edit

Oh, nvm. Brainfart. You’d still need a class to declare delegates like that. Just UCLASS wouldn’t be mandatory.