Unrecognized type 'FArchive' - type must be a UCLASS, USTRUCT or UENUM

I am trying to create a save/load system using Rama’s tutorial on the Wiki.

For some reason my code won’t compile, and is complaining that FArchive is an unrecognised type, despite trying both forward declaration and/or header inclusion.

Here is the header for the file which halts compilation:

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "FileOperators.h"
#include "Serialization/Archive.h"
#include "FileSystem.generated.h"

class FArchive;
class USettings;

UCLASS(Blueprintable)
class THE_API UFileSystem : public UObject
{
	GENERATED_BODY()
	
public:

	UFileSystem();

	// --------------------------------
	// Saving and Loading
	// --------------------------------
	
	UFUNCTION(BlueprintCallable)
	void SaveLoadData(FArchive& Ar, USettings* Settings);

};

This won’t compile, it complains:

Unrecognized type 'FArchive' - type must be a UCLASS, USTRUCT or UENUM

As I said, I have tried forward declaration of FArchive, and including the header for Archive.h, and even both at the same time, but nothing works.

What’s going on here?!

Figured it out straight away - oops!

It’s because I was trying to make the function Blueprintcallable, and since FArchive isn’t usable in Blueprint, that was what was throwing the error.

Leaving original post here in case anyone else makes this mistake.

1 Like