Generated.h exist but cannot be included

In a module, I have the include for a generated.h file

#include "KJSonStructs.generated.h"


USTRUCT()
struct FKJsonParamEmailPass
{
	GENERATED_USTRUCT_BODY()

		UPROPERTY()
		FString uemail;

	UPROPERTY()
		FString upassword;

	UPROPERTY()
		FString clientid;

	UPROPERTY()
		int32 servertype;

	/** constructor */
	FKJsonParamEmailPass(const FString& InEmail = TEXT(""), const FString& InPass = TEXT(""), const FString& InClientId = TEXT(""), const int32 InServerType = 0)
	{
		uemail = InEmail;
		upassword = InPass;
		clientid = InClientId;
		servertype = InServerType;
	}
};

The file exist in the directory Inc, but cannot be included.

fatal error C1083: Cannot open include file: ‘KJSonStructs.generated.h’: No such file or directory

The file is part of a module.

Is there a specificity with modules ?

Hello ,

Is this code in the KJSonStructs.h file? Have you tried generating your project files since adding this file to your project?

If this isn’t KJSonStructs.h, you’ll need to include that file instead of its .generated.h, as .generated.h files are only meant to be included in the file they’re generated from.

We haven’t heard from you in a while, . Are you still experiencing this issue? If so, can you provide the information mentioned in my previous comment? In the meantime, I’ll be marking this issue as resolved for tracking purposes.

Hello Matthew,

Sorry for not responding to your answer.
Yes this code is in the KJsonStructs.h

I understood that when you have GENERATED_USTRUCT_BODY() you need to add the .generated.h include since the Unreal Header Tool is generating code.

In the meantime, I removed this file and place the code in another header file.

But I have no idea why it is not working for this file especifically.

D.

I’m not sure if this is just a typo from your answerhub post, but it seems that there may be a capitalization mistake here that is causing this. In your include statement, the first S in KJsonStructs.h is capitalized, but it is not capitalized in your struct declaration and seemingly not capitalized in the file name either (based off your comment.) Can you try fixing this capitalization error to see if that is what is causing this?

It is a misspelling in my answer…

Did you generate your project files again after adding this header file?

I created a blank C++ project and went to recreate what you showed by putting the following code into a header file and adding it to the project:

#pragma once

#include "MyStruct.generated.h"

USTRUCT()
struct FMyStruct
{
	GENERATED_USTRUCT_BODY()

};

After adding this file, I generated project files so that it was added to the solution and compiled without an issue.

For other files no problem. I had this problem for this specific file.
Whatever, I moved its content to another file and it generates correctly.