How pass function to argument?(C++)

How pass func(from bp or not) in argument?

DECLARE_DELEGATE(FuncName);
UFUNCTION(BlueprintCallable)
void SomeFuncToPass(FuncName& fn);

This not work.
P.S Log: (2) Error: Unrecognized type ‘FuncName’ - type must be a UCLASS, USTRUCT or UENUM

My experience using it in a function was like this:

FunctionTakingDelegate(FNameOfDelegate Function)
{
      if(Function.IsBound())
      {
            //Do stuff
      }
}

Nothing fancy in this case. Probably ain’t quite right, but I didn’t think much of it since the delegate effectively only transfers access to the function anyway.

What does “This not work” means? Any errors, logs?

(2) Error: Unrecognized type ‘FuncName’ - type must be a UCLASS, USTRUCT or UENUM

It sounds like you’ve wrongly placed your delegate declaration. Delegates need to be declared after your includes, but before any class declaration, ie like this:

#include "YourClass.generated.h"

DECLARE_DYNAMIC_DELEGATE(FFuncName);

UCLASS()
class AClass : public AParentClass
{
      GENERATED_BODY()
      //Rest of class...

Do you mind giving us the full code from the first line up until the GENERATED_BODY() of the class?

EDIT: I see you’ve updated your question. In your case, I believe you are looking to use DECLARE_DYNAMIC_DELEGATE, not DECLARE_DELEGATE. A blueprint cannot use a regular delegate to my knowledge, as it is not compatible with Unreal’s reflection system as I’ve understood it.

This may be due to “UFUNCTION(BlueprintCallable)”?
Just i tried so

DECLARE_DELEGATE(FuncName);
void TestFunc(FNameFunc f);

And it compile.

Yes. As mentioned, blueprints cannot use a “regular” delegate, hence you need to use the “DYNAMIC” keyword instead.

Try this.

 DECLARE_DYNAMIC_DELEGATE(FuncName);
 UFUNCTION(BlueprintCallable)
 void SomeFuncToPass(FuncName& fn);

if

 DECLARE_DYNAMIC_DELEGATE(FNameFunc);
  UFUNCTION(BlueprintCallable)
  void SomeFuncToPass(FNameFunc fn);

then :

Error PyCharacter.cpp.obj : error LNK2019: unresolved external symbol “public: void __cdecl APyCharacter::TestFunc(class FNameFunc)” (?TestFunc@APyCharacter@@QEAAXVFNameFunc@@@Z) referenced in function “public: void __cdecl APyCharacter::execTestFunc(struct FFrame &,void * const)” (?execTestFunc@APyrCharacter@@QEAAXAEAUFFrame@@QEAX@Z)

if :

     DECLARE_DYNAMIC_DELEGATE(FNameFunc);
      UFUNCTION(BlueprintCallable)
      void SomeFuncToPass(FNameFunc& fn);

then :
(13) error C4239: nonstandard extension used: ‘argument’: conversion from ‘FNameFunc’ to ‘FNameFunc &’
(13): note: A non-const reference may only be bound to an lvalue
(13) : error C4239: nonstandard extension used: ‘argument’: conversion from ‘FNameFunc’ to ‘FNameFunc &’
(13) : note: A non-const reference may only be bound to an lvalue

(13) string :

	GENERATED_BODY()

Drop the ampersand, ie from FNameFunc& to instead just FNameFunc?

Just remember declare body