# Source file cannot be opened generated.h

**URL:** <https://forums.unrealengine.com/t/source-file-cannot-be-opened-generated-h/464973>\
**Category:** C++\
**Tags:** unreal-engine, generated, CPP, question\
**Created:** [May 10, 2020, 7:18pm UTC](https://forums.unrealengine.com/t/source-file-cannot-be-opened-generated-h/464973 "2020-05-10T19:18:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![odmin369](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@odmin369](https://forums.unrealengine.com/u/odmin369)\
**Post date:** [May 10, 2020, 7:18pm UTC](https://forums.unrealengine.com/t/source-file-cannot-be-opened-generated-h/464973/1 "2020-05-10T19:18:12Z")

</div>

When I compile a C++ file or create a new C++ file, I often fail to include generated.h.  
Try Generate VisualStudio Project File  
Deleting the Intermediate,Saved folder and running the Generate VisualStudio Project File did not fix the problem.  
This makes it impossible to launch UE4 from either the solution or from the uproject.  
What is the solution?

---

<div class="post-metadata">

**Author:** ![xyah1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xyah1](https://forums.unrealengine.com/u/xyah1)\
**Post date:** [May 11, 2020, 2:58am UTC](https://forums.unrealengine.com/t/source-file-cannot-be-opened-generated-h/464973/2 "2020-05-11T02:58:22Z")

</div>

You have to write the #include “\_\_\_\_.generated.h” if it’s not there and if you are using Unreal Macros for the class/struct(e.g. UCLASS, USTRUCT, etc)  
Even if the generated.h is in red line, once you run the Unreal Header Tool, the generated file should be created.

Please post screenshots if you still have issues compiling.

---

<div class="post-metadata">

**Author:** ![odmin369](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@odmin369](https://forums.unrealengine.com/u/odmin369)\
**Post date:** [May 12, 2020, 12:38pm UTC](https://forums.unrealengine.com/t/source-file-cannot-be-opened-generated-h/464973/3 "2020-05-12T12:38:16Z")

</div>

Thank you for your reply.  
Apparently, IntelliSense was freaked out and all the files with .generated were showing red lines.  
The error itself was a mistake on my part, as it occurred elsewhere and there was no red line in it.
