Compiling a UEdGraph class in a plugin with UCLASS() fails

Hi everyone!

I’m currently attempting to extend the graphical editors of the engine to allow me to create and modify some custom asset files in a Blueprint-like environment. I’ve got my plugin set up, and I can create new factories of my asset type. However, when I began work on creating the actual editor, I ran into some issues.

I can create a class derived from UEdGraph fine, and it will compile as expected until I add the UCLASS() macro with its corresponding GENERATED_BODY(). When these two lines are present in the file, the compilation fails with this error:


Reflection code generated for DialogueGraphProjectEditor in 5.5658969 seconds
Performing 3 actions (8 in parallel)
[1/3] Compile DialogueGraph.cpp
In file included from /home//Documents/Unreal Projects/DialogueGraphProject/Plugins/DialogueEditor/Source/DialogueEditor/Private/DialogueGraph.cpp:2:
/home//Documents/Unreal Projects/DialogueGraphProject/Plugins/DialogueEditor/Source/DialogueEditor/Private/DialogueGraph.h:9:1: error: unknown type name 'Engine_Source_Editor_UnrealEdMessages_Classes_FileServerMessages_h_9_PROLOG'
UCLASS(Abstract, MinimalAPI)
^
/home//Programming/UnrealEngine/Engine/Source/Runtime/CoreUObject/Public/UObject/ObjectBase.h:576:21: note: expanded from macro 'UCLASS'
#define UCLASS(...) BODY_MACRO_COMBINE(CURRENT_FILE_ID,_,__LINE__,_PROLOG)
                    ^
/home//Programming/UnrealEngine/Engine/Source/Runtime/CoreUObject/Public/UObject/ObjectBase.h:563:37: note: expanded from macro 'BODY_MACRO_COMBINE'
#define BODY_MACRO_COMBINE(A,B,C,D) BODY_MACRO_COMBINE_INNER(A,B,C,D)
                                    ^
/home//Programming/UnrealEngine/Engine/Source/Runtime/CoreUObject/Public/UObject/ObjectBase.h:562:43: note: expanded from macro 'BODY_MACRO_COMBINE_INNER'
#define BODY_MACRO_COMBINE_INNER(A,B,C,D) A##B##C##D
                                          ^
<scratch space>:3:1: note: expanded from here
Engine_Source_Editor_UnrealEdMessages_Classes_FileServerMessages_h_9_PROLOG
^
... snip cascading errors

I’ve included UnrealEd and GraphEditor as private dependency modules, but perhaps there’s something more I’m missing? Any help would be greatly appreciated.
These are the relevant source files:

DialogueGraph.h


#ifndef DIALOGUEGRAPH
#define DIALOGUEGRAPH
#pragma once

#include "DialogueEditorPrivatePCH.h"
#include "GraphEditor.h"
//#include "DialogueGraph.generated.h"

UCLASS(Abstract, MinimalAPI)
class UDialogueGraph : public UEdGraph
{
    GENERATED_BODY()

public:
    void RefreshGraph();
private:
    void RemoveAllNodes();
};

#endif // DIALOGUEGRAPH



DialogueGraph.cpp


#include "DialogueEditorPrivatePCH.h"
#include "DialogueGraph.h"

#define LOCTEXT_NAMESPACE "DialogueGraph"

void UDialogueGraph::RefreshGraph()
{
    RemoveAllNodes();
}

void UDialogueGraph::RemoveAllNodes()
{
    TArray<UEdGraphNode*> NodesToRemove = Nodes;
    for (UEdGraphNode* Node : NodesToRemove)
    {
        RemoveNode(Node);
    }
}

#undef LOCTEXT_NAMESPACE


DialogueEditorPrivatePCH.h


// Some copyright should be here...

#include "Core.h"
#include "Engine.h"
#include "UnrealEd.h"

#include "DialogueEditor.h"

// You should place include statements to your module's private header files here.  You only need to
// add includes for headers that are used in most of your module's source files though.


Solved! I got some help from enlight on the IRC. Turns out having #ifndef in the headers screws things up, as well as having the PCH included in the headers. It now compiles fine :slight_smile:

1 Like