P_NATIVE_BEGIN, P_NATIVE_END, P_FINISH, not defined

Hey all, I’m getting a weird set of errors whenever I try to use a UFUNCTION inside of a plugin.

The errors are:

2>ExampleStruct.h(19): error C2065: ‘P_FINISH’: undeclared identifier

2>ExampleStruct.h(19): error C2065: ‘P_NATIVE_BEGIN’: undeclared identifier

2>ExampleStruct.h(19): error C2065: ‘P_NATIVE_END’: undeclared identifier

2>ExampleStruct.h(19): error C2065: ‘P_FINISH’: undeclared identifier

2>ExampleStruct.h(19): error C2065: ‘P_NATIVE_BEGIN’: undeclared identifier

2>ExampleStruct.h(19): error C2065: ‘P_NATIVE_END’: undeclared identifier

#pragma once

#include <Object.h>
#include "ClassLibrary/ClassLibrary.h"
#include "ExampleStruct.generated.h"

USTRUCT(BlueprintType)
struct FStruct1Unreal
{
	GENERATED_BODY()

	UPROPERTY()
	FString x;
};

UCLASS(Blueprintable)
class EXAMPLE_API UExample : public UObject
{
	GENERATED_BODY()

public:
	UExample(FObjectInitializer const & ObjectInitializer);
	virtual ~UExample();

public:
	UFUNCTION(BlueprintCallable, Category = "example")
	void Start();
};

You need to add

#include <UObject/ObjectMacros.h>

that was changed with 4.15, object macros (UFUNCTION, UPROPERTY, etc) aren’t globally provided anymore.

Still getting the same error, sadly.

Ah, you also need to change the GENERATED_BODY to GENERATED_USTRUCT_BODY in your Struct.

If you changed that macro to GENERATED_USTRUCT_BODY you may need to clean and rebuild your solution to get the UHT to re-generate that file. Other than that, everything looks fine.

Hmmm… Try one last thing. Add

#include UObject/ScriptMacros.h

Still nada. Problem persists.

I usually build with “Rebuild” for that exact reason. But to be safe, I also deleted my Binaries and Intermediate folders for both the plugin and the main project, re-generated Visual Studio files, and the problem still occurs.

That worked. Thanks, this sunk like 3.5 hours of my day. I’ll buy you lunch if we ever meet in person.

Coooooooooooooooooooooooooooooooool