Compiling fails as soon as I add a second UCLASS!?

Hello I started to develop an Artnet Plugin. Sending the packages works fine now. But when I wanted to programm a udp Receiver I ran in to some strange compiling errors. I’m using Visual Studio Community 2015.

I created the plugin in the unreal engine via going to plugins-> new plugin → Blueprint library

my ArtNet.build.cs looks like this:

using UnrealBuildTool;

public class ArtNet : ModuleRules
{
	public ArtNet(TargetInfo Target)
	{
		
		PublicIncludePaths.AddRange(
			new string[] {
				"ArtNet/Public"
				
				// ... add public include paths required here ...
			}
			);
				
		
		PrivateIncludePaths.AddRange(
			new string[] {
				"ArtNet/Private",
				
				// ... add other private include paths required here ...
			}
			);
			
		
		PublicDependencyModuleNames.AddRange(
			new string[]
			{
				"Core",
				"Sockets",
				"Networking"
				
				// ... add other public dependencies that you statically link with here ...
			}
			);
			
		
		PrivateDependencyModuleNames.AddRange(
			new string[]
			{
				"CoreUObject",
				"Engine",
				"Slate",
				"SlateCore",

				// ... add private dependencies that you statically link with here ...	
			}
			);
		
		
		DynamicallyLoadedModuleNames.AddRange(
			new string[]
			{
				// ... add any modules that your module loads dynamically here ...
			}
			);
	}
}

So in the “public” folder ther is my “ArtNetBPLibrary.h”. It looks like this:

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "Engine.h"
#include "ArtNetBPLibrary.generated.h"


UCLASS()
class UArtNetBPLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_UCLASS_BODY()

	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Setup ArtNet-UDP-Networking", Keywords = "ArtNet initialize dmx"), Category = "ArtNet")
	static void SetupArtNetUDPNetworking(const FString& DestinationIP = "192.168.0.1", const int32 DestinationPort = 6454, const int32 SourcePort = 6454);
	
	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Set ArtNet-DMX-Package-Routing", Keywords = "ArtNet header set dmx"), Category = "ArtNet")
	static void SetArtNetRouting(int net = 0, int subnet = 0, int universe = 0);
	
	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Set DMX Channel", Keywords = "ArtNet DMX channel set"), Category = "ArtNet")
	static void SetDmxChannel(int channel = 1, int value = 0, bool valueInPercent = true);
	
	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Set all DMX Channels", Keywords = "ArtNet DMX channels set all"), Category = "ArtNet")
	static void SetAllDmxChannels(int value = 0, bool valueInPercent = true);
	
	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Send ArtNet-DMX-Package", Keywords = "ArtNet DMX send"), Category = "ArtNet")
	static void SendArtNetDMXPackage(bool useSequencing = true);
	
};

Everything works fine until here. It compiles and my blueprints work inside of Unreal. But when I add another declaration to the file it doesn’t compile anymore. For example when I add this right below the code:

UCLASS()
class ArtNetUDPReceiver : public UBlueprintFunctionLibrary
{
	GENERATED_UCLASS_BODY()
};

or the exact same error, when I add a Ustruct instead:

USTRUCT(BlueprintType)
struct ArtNetDMXData
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ArtNetProp")
	int Squence = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ArtNetProp")
	int Net = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ArtNetProp")
	int Subnet = 0;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ArtNetProp")
	int Universe = 0;

	ArtNetDMXData()
	{}
};

Unfortunately the error message is in german and I can’t get my visual studio to report the errors in english!
It says: “Diese Deklaration hat keine Speicherklasse oder keinen Typspezifizierer”

Any ideas on what I’m doing wrong?
I also tried to make a new file for the “ArtNetUDPReceiver”, but in this .h file it was exactly the same…

Any help is highly appreciated! Thanks in Advance,
Johannes

First thing i can see wrong here is fact that you not follow naming convention and it could mess up code generated by UHT. UObjects should start with letter “U”, AActors with “A”, Structs with “F”

2nd is that you use default int, reflection system does not support them due fact that each compiler for specific platform can have different default int size set (or else something changed that i don’t know). Reflection system supports only int32 (Integer type in blueprints) and uint8 (Byte type in blueprints). If you use type unsupported by reflection system it can compile, but you will have useless invalid type pin in node or gray out text box in properties.

Also something tells me that UArtNetUDPReceiver is not just for static nodes, if this suppose to be a object that somebody can create it should derived from UObject not UBlueprintFunctionLibrary. UBlueprintFunctionLibrary is for node libraries with static functions that you can’t assign to particular class. Also note that static classes work the same anywhere, it makes no difference for BP.

Thanks for the tipps! I changed all “int” to “uint8” and “int32” and put an F in front of the struct name. The Ustruct works fine, now! Thanks.
And yes you are right, it doesn’t make any sense to derive from UBluepritnFunctionLibrary with my new class. I just ended up trying this, because a few lines above the exact same code works… so i thought, maybe it works if I make it the exact same.
Ok, I now derived it from AActor and put an “A” before the name. But I still can’t get the class to compile.

UCLASS()
class AArtNetUDPReceiver : public AActor
{
	GENERATED_UCLASS_BODY()
};

Still the same error. I also tried to derive from UObject and put an"U" before the name:

UCLASS()
class UArtNetUDPReceiver : public UObject
{
	GENERATED_UCLASS_BODY()
};

The same. Any Idea?

change GENERATED_UCLASS_BODY to GENERATED_BODY, also try rebuilding

Thanks! Using “GENERATED_BODY” worked. I don’t understand why there is a problem with GENERATED_UCLASS_BODY though.

But now, as soon as I move this class (the exact same code) in it’s own .h file with including the exact same headers it stopps building, again with the same error… (the new file is also in the same directory)

Ok, I got it working!

This article about the Unreal Reflection System helped me alot: Unreal Property System (Reflection) - Unreal Engine

So the key was to include the xxx.generated.h file and afterwards hit “generate visual studio files”:

#include “FileName.generated.h”