Cannot open generated.h file

I’ve made a class with no preset parent class called Neuron as I’m trying to make a neural network that is integrated with UE4. When I compiled it with my basic design, I got the error cannot open source file “Neuron.generated.h”. I get the feeling that my other 20 or so errors are related to this as they are to do with UNFUNCTIONs, USTRUCTs and UENUMs, which are ■■■ far as I can tell are found in this generated file, which cannot be accessed. The code to include it is in the .h file:

#pragma once

#include "CoreMinimal.h"
#include "Neuron.generated.h"

I had to add it in myself as VS didn’t when I first opened it, so I may have made some error in that. I closed VS, generated files from the explorer and recompiled it, but it didn’t work. Any solutions?

Hey,

delete intermediate directory, right click uproject → generate vs project files. Open - Compile.

This didn’t work. I think it’s because I chose it to be an empty class, so how do I fix this? I’m thinking that I could still make my original goal possible if it was an actor component, but I don’t know how to convert an empty class to a child of the ActorComponent class.

My main code in my header file:

UCLASS(BlueprintType)
class DIVERGENTNEURALNET_API Neuron

{
public:


	GENERATED_BODY()
		Neuron(int toldLayerNumber, int toldSectionNumber, int totalNumLayersInSection, ESectionType sectionType);

	int layerNumber;
	int sectionNumber;
	float value;
	ELayerType layerType;
	ESectionType sectionType;

	// From x to x+1 layer
	UFUNCTION(BlueprintCallable)
		void FeedForward(TArray<Synapse>* FSynapses, TArray<Neuron>* FinputLayers, Finput FinputValue);
};

cpp file:
Neuron::Neuron(int toldLayerNumber, int toldSectionNumber, int totalNumLayersInSection, ESectionType sectionType)
{
layerNumber = toldLayerNumber;
sectionNumber = toldSectionNumber;
//By default, the layer type will be hidden.
layerType = ELayerType::Hidden;
inputImage = input.sourceImage;

	// total numbers of layers in section variable will be handled by the Net class.
	// This class is handling the neuron's functionality and the FSynapses between neurons. 

	// Determines the layer type for each instance of the class so it knows its inputs and outputs if necessary
	if (toldLayerNumber == 0) {
		layerType = ELayerType::Input;
	}
	else if (toldLayerNumber >= totalNumLayersInSection) {
		layerType = ELayerType::Output;
	}
	else{
		layerType = ELayerType::Hidden;
	}
}

void Neuron::FeedForward(TArray<Synapse>* FSynapses,TArray<Neuron>* InputLayers,FinputinputValue) {
	int n = 0;
	UTexture2D inputImage = inputValue.soureImage;
	const FColor* FormatedImageData = static_cast<const FColor*>(inputImage->PlatformData->Mips[0].BulkData.LockReadOnly());

	for (i InputLayers : array) {
		i.value = FormatedImageData[n];
		++n;
	}
	inputImage->PlatformData->Mips[0].BulkData.Unlock();
}

If you want a “generic class” that you can use with blueprints (UPROPERTY, UFUNCTION) etc. you need to derive from UOBJECT. Not an empty class.

Just to add a bit more colour - all of those U-macros are only available to UOBJECT class and any of its derivatives. The generated.h headers are actually created during the process of “compiling” your project (I put the term “compiling” in quotes because when you compile in unreal you directly or indirectly use the unrealbuildtool that does a lot more things than just compile. Somewhere in that process, the U-macros are processed and create the linkages to blueprint that you control with the U-macro parameters (EditAnywhere, BlueprintReadWrite etc…)

Create a new class derived from UObject or some child class (Actor is one of them) then copy your code from the old .h file to the new .h file and from the old .cpp file to the new.cpp file.

To delete the old class, follow these instructions:

How to delete a C++ class