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"

Function with same name than Ufunction

Hi,

I noticed that creating a function with the same name than an Ufunction of the base class, even with different signatures, confuses the compiler a lot.

As an example, the Primitive Component declares the following Ufunction:

 UFUNCTION(BlueprintCallable, Category="Rendering|Material")
 virtual void SetMaterial(int32 ElementIndex, class UMaterialInterface* Material);

Inheriting from it, I declare a function with the same name but different signature:

 UCLASS()
 class UFooMeshComponent : public UPrimitiveComponent
 {
     GENERATED_UCLASS_BODY()
 public:
     void SetMaterial( UMaterial* InMaterial );
 };

I get the following compiler warnings:

 FooMeshComponent.h(12): warning C4263: 'void UFooMeshComponent::SetMaterial(UMaterial *)' : member function does not override any base class virtual member function
 
 FooMeshComponent.h(13): warning C4264: 'void UPrimitiveComponent::SetMaterial(int32,UMaterialInterface *)' : no override available for virtual member function from base 'UPrimitiveComponent'; function is hidden
 
 Engine\Source\Runtime\Engine\Classes\Components/PrimitiveComponent.h(624) : see declaration of 'UPrimitiveComponent::SetMaterial'
 
 Engine\Source\Runtime\Engine\Classes\Components/PrimitiveComponent.h(102) : see declaration of 'UPrimitiveComponent'

So different things confuse me here:

  • I know this is a poor choice of names anyway but why is that an issue at all to the compiler since the signatures are different? I'm not using "override" here. Is the compiler being somehow too smart? Or is it something with the additional code generated by UHT?

  • Could UHT catch this sort of mistakes earlier on, as it does with implementations of overridden interface functions?

Product Version: Not Selected
Tags:
more ▼

asked Mar 18 '15 at 10:21 AM in C++ Programming

avatar image

G4m4
690 27 15 34

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

1 answer: sort voted first

No OverLoading UFUNCTION

You can't overload a UFUNCTION()

So use unique names :)

Rama

PS: I dont know all the reasons why, but I dont think you are getting around this restriction any time soon

more ▼

answered Mar 19 '15 at 09:11 PM

avatar image

Rama
10.6k 446 345 1088

avatar image G4m4 Mar 26 '15 at 03:25 PM

That's still a weird behaviour. But okay, I understand there's some magic involved. Thanks!

(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