Adding Unreal Interface Does Not Compile

When I an Unreal interface with the engine, I get the following compilation errors. I’ve also included the code that is generated by Unreal.

PickupInterface.h(11): error C2504: ‘UInterface’: base class undefined

PickupInterface.h(12): error C3646: ‘Super’: unknown override specifier

PickupInterface.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

PickupInterface.h(12): error C2614: ‘UPickupInterface’: illegal member initialization: ‘Super’ is not a base or member

PickupInterface.h(12): error C2440: ‘return’: cannot convert from ‘UPickupInterface *’ to ‘UObject *’

PickupInterface.h(12): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

#pragma once

#include "CoreMinimal.h"
#include "PickupInterface.generated.h"

// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UPickupInterface : public UInterface
{
	GENERATED_BODY()
};

/**
 * 
 */
class TOMBWORLD_API IPickupInterface
{
	GENERATED_BODY()

	// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
	
	
};

Hey there.

Have you tried including Interface.h?

#include "UObject/Interface.h"

From what I see, it’s not directly included in CoreMinimal.h. It might be somewhere deeper tho.

I am incredibly confused. I added the Interface header, and it still failed. I added core minimal, same thing. Swapped the order and it worked. Then I removed both and it still compiles. I have no idea why, there is nothing else I changed. Thanks for the help, I do wish I knew what the issue was though.

It seemed kind of odd that you had this error in the first place. I can’t remember if I ever had to include this header explicitly anywhere in my code actually. Maybe forcing VS to actually recompile your stuff fixed the issue. That’s actually quite common solution. :stuck_out_tongue:

I am not sure if I am experiencing the same thing but in a different form, but it maybe has to do with in what order you include the Interface header file, as it compiled fine until I moved the #include for the interface in my other classes to right before the .generated.h file. Not sure though

I have the same problem and was working 2 days on it being confused. My code was the same as the example and it just wouldn’t work. But somehow, switching some property orders or moving the #import made me able to compile? I have no idea what the problem is but hopefully the #import is the answer and it’ll work from now on.