# no generated.h file

**URL:** <https://forums.unrealengine.com/t/no-generated-h-file/107387>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [March 5, 2018, 6:35am UTC](https://forums.unrealengine.com/t/no-generated-h-file/107387 "2018-03-05T06:35:40Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![NeveraiN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NeveraiN](https://forums.unrealengine.com/u/NeveraiN)\
**Post date:** [December 2, 2021, 5:54pm UTC](https://forums.unrealengine.com/t/no-generated-h-file/107387/8 "2021-12-02T17:54:06Z")

</div>

for anyone with the same issue.

## English Version

1. add a new \*.h file
2. add the following code

```auto
#include "CoreMinimal.h"

USTRUCT(BlueprintType)
struct FMyNewStruct
{
	GENERATED_BODY()
};

```

  - Note: Struct name start with F
  - Note: GENERATED\_BODY is required

3. Build Solution
  - Note: there will be compile error, just ignore
  - Note: you can not find the new struct in UE Editor
  - Note: this compile action will start UnrealHeaderTool that will generate \*.generated.h

4. Edit code，include \*.generated.h

```auto
#include "CoreMinimal.h"
#include "MyNewStruct.generated.h"

USTRUCT(BlueprintType)
struct FMyNewStruct
{
	GENERATED_BODY()
};

```

5. Build Solution AGAIN!
  - build will success
  - and struct can be found in UE Editor

# 中文版

1. 在工程目录添加一个.h文件
2. 添加如下代码

```auto
#include "CoreMinimal.h"

USTRUCT(BlueprintType)
struct FMyNewStruct
{
	GENERATED_BODY()
};

```

  - 注意：Struct必须以F开头
  - 注意：GENERATED\_BODY不能省去

3. 生成项目
  - 注意，此时会报错，不用关注
  - 注意，此时在UE编辑器中仍旧找不到该新建Struct
  - 此次编译的目的：触发一次UnrealHeaderTool，生成文件对应的.generated.h文件

4. 修改代码，包含.generated.h

```auto
#include "CoreMinimal.h"
#include "MyNewStruct.generated.h"

USTRUCT(BlueprintType)
struct FMyNewStruct
{
	GENERATED_BODY()
};

```

5. 再次生成项目
  - 此时可以成功编译
  - 引擎中也能找到类型定义

---

_[View the full topic](https://forums.unrealengine.com/t/no-generated-h-file/107387)._
