Download

Error creating an Interface class in UE 4.16.3

Hi,

I have created interfaces in c++ before and I have never face this error. The steps I have followed are:

  • Create a C++ class from Editor derived from UObject
  • Delete content in .h file and write:


#include "IKADestroy_I.generated.h"

UINTERFACE(Blueprintable)
class UIKADestroy_I : public UInterface
{
    GENERATED_BODY()
};

class IDestroy
{
    GENERATED_BODY()

};


Then compile the solution and…

1>LogWindows : error : === Critical error: ===
1>LogWindows : error :
1>LogWindows : error : Assertion failed: InterfaceGeneratedBodyLine > 0 [File:d:\build++ue4+release-4.16+compile\sync\engine\source\programs\unrealheadertool\private\ParserHelper.h] [Line: 1560]
1>LogWindows : error :

Someone knows what’s happening??

Thanks in advance

EDIT: I have installed VS 20015 Update 3 (I had Update 2) and UE 4.18… still the same error. it’s crazy…

You don’t have the API name in there. Interface should look like this. I think that should fix it.



#pragma once

#include "MyInterface.generated.h"


/**        */
UINTERFACE()
class EXAMPLEPROJECT_API UMyInterface : public UInterface
{
    GENERATED_BODY()
};

/**        */
class EXAMPLEPROJECT_API IMyInterface
{
    GENERATED_BODY()


};


Replace exampleproject with name of your project.

Hi Ninja_K,

Thanks for your message. Unfortunately I had checked it before and it does not worked. (I have tried it again without success).

Regards

I have fixed it. I don’t really fixed but now I know the correct way to create a c++ interface in Unreal. Now, when you create a new c++ class from the editor, you can chosse ‘Unreal Interface’ class, I did not know it.

the generated code is the same that I did manually but I suppose that there are some changes in the .generated file.

Bye!

For anyone else that runs into this, this is the issue: The original post’s code contained class UIKADestroy_I : public UInterface and class IDestroy, and these don’t match. When UHT comes across a UINTERFACE macro, it replaces the first character of the class name from “U” to “I” to come up with the name of the corresponding interface class that it expects to find. OP received the error because UHT couldn’t find a declaration called IIKADestroy_I.

The fix in this case would be to rename UIKADestroy_I to UDestroy, or to rename IDestroy to IIKADestroy_I.

The answer to this assertion is also mentioned here.