x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Using Function Pointer as parameter raises error

Hey all!

So I am using a method which uses a Function Pointer as an input parameter.

This is how the declaration and definition look like:

.h

 UFUNCTION()
         bool PerformTask(void (AItem::*FunctioPtr)(), uint8 Priority, float Length, bool bSuspendEqualPriority = false);

.cpp

  bool AItem::PerformTask(void (AItem::*FunctioPtr)(), uint8 Priority, float Length, bool bSuspendEqualPriority)
     {
         //...
     }

This setup worked in a prior project, but now it raises a "Unrecognized type 'void'" error. Why is this happening and how could I resolve it?

Thanks!

Product Version: Not Selected
Tags:
more ▼

asked Nov 15 '14 at 01:23 PM in C++ Programming

avatar image

Fluppi393
457 36 33 54

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

UFUNCTION() ?

Does your function have to be UFUNCTION()?

Does it compile if you dont use UFUNCTION() ?

Let us know!

Rama

more ▼

answered Nov 16 '14 at 05:48 PM

avatar image

Rama
10.6k 446 345 1088

avatar image Fluppi393 Nov 16 '14 at 07:16 PM

Omitting the UFUNCTION() declaration did actually solve the problem!

Thanks Rama, also for your article about function pointers!

avatar image Anry Narleyn Aug 24 '16 at 08:11 PM

Greetings, guys. I've got similar question. So is it possible somehow to use function pointers with UFUNCTION macro to call them from blueprints?

avatar image Fluppi393 Aug 24 '16 at 08:48 PM

I don't think that's possible. However you could use the function name as a parameter (the function to call needs to be a UFUNCTION too) and then execute that function via ProcessEvent(FindFunction(FunctionName), NULL) on a UObject derived object.

avatar image Anry Narleyn Aug 25 '16 at 01:11 PM

Thanks, Fluppi, I think that it should work in my case. At least I will try :)

avatar image Ryan Darcey Feb 28 '17 at 05:55 PM

I got this syntax compiling for function declaration, but not sure exactly how to call the function passed in as the parameter. Any ideas?

 void APFCharacter::Exclaim(void (APFCharacter::*ExclaimFunc)(void))
 {
     (this->*ExclaimFunc())();
 }

Here's the error:

12>C:\UnrealEngine\Prizefighter\Source\Prizefighter\Private\PFCharacter.cpp(719): error C2064: term does not evaluate to a function taking 0 arguments

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question