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"

Can't place UInterface and it's implementation class in one header?

I'm now meet a problem:

 UINTERFACE(MinimalAPI,BlueprintType, meta = (CannotImplementInterfaceInBlueprint))
 class UTestInterface : public UInterface
 class TEST_API ITestInterface
 UCLASS(NotBlueprintable, NotBlueprintType)
 class TEST_API UTestInterfaceImpl : public UObject, public ITestInterface

I place UTestInterface,UTestInterface and UTestInterfaceImpl in one header, and the UHT says:"error : Class 'UTestInterface' contains a dependency (#include or base class) to itself",After I move UTestInterfaceImpl to another file,there have no error anymore.
At first, I think it is because UBT doesn't allow to do this, but I find UHT allow the user to place multiple UCLASS declarations in one header.
So I'm confused. Why Multiple UClass is OK, but UInterface can't do the same thing?

Product Version: UE 4.20
more ▼

asked Nov 07 '18 at 11:39 AM in C++ Programming

avatar image

Jack Myth
149 10 16 24

avatar image Shadowriver Nov 07 '18 at 08:52 PM

This has nothing to do for number of classes in file, it depency issue as error suggests, what are includes you making?

avatar image Jack Myth Nov 08 '18 at 05:06 AM

Nothing Special: TestA.h:
#include "CoreMinimal.h"
#include "Interface.h"
#include "TestB.h"
#include "SubclassOf.h"
#include "TestA.generated.h"

#include "CoreMinimal.h"
#include "UObject/Object.h"
#include "Classes/BlueprintJsonLibrary.h" //It's a plugin's header
#include "TestB.generated.h"

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "BlueprintJsonLibrary.generated.h"

error : Class 'TestA' contains a dependency (#include or base class) to itself

After I Move the declaration of TestAImpl to TestAImpl.h,It successfully compiled, I don't even change any include in TestA.h(TestAImpl.h include TestA.h)

avatar image DarkwindRichard Nov 15 '18 at 04:37 PM

Hi Jack,

The error seems to go away for me if I delete UTestInterface. Do you need to interact with the interface from Blueprint, or are your implementations of the interface only for use by C++ (as in the case of UTestInterfaceImpl)?

avatar image Jack Myth Nov 15 '18 at 04:51 PM

I need to use it in Blueprint,that is why I use UIneterface.

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

1 answer: sort voted first

Hi Jack,

I looked internally, and this bug has already been reported and is currently assigned to a developer. In the meantime, it seems like the only workaround is to split up the interface and the class that implements it.

more ▼

answered Nov 15 '18 at 09:31 PM

DarkwindRichard (suspended)
avatar image Jack Myth Nov 16 '18 at 03:34 AM

I‘m glad to hear that. 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