# Class definition breaks after adding #include

**URL:** <https://forums.unrealengine.com/t/class-definition-breaks-after-adding-include/426916>\
**Category:** Community & Industry Discussion\
**Tags:** include, unreal-engine, question\
**Created:** [June 7, 2018, 10:32pm UTC](https://forums.unrealengine.com/t/class-definition-breaks-after-adding-include/426916 "2018-06-07T22:32:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dexgecko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dexgecko](https://forums.unrealengine.com/u/Dexgecko)\
**Post date:** [June 7, 2018, 10:32pm UTC](https://forums.unrealengine.com/t/class-definition-breaks-after-adding-include/426916/1 "2018-06-07T22:32:05Z")

</div>

I have the following header file which compiles with no errors:

```
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Grabber.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
	GENERATED_BODY()

public:	
	UGrabber();

protected:
	virtual void BeginPlay() override;

public:	
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

private:
	APlayerController* player;
	FVector PlayerViewLocation;
	FRotator PlayerViewRotation;
	float Reach = 100.f;
};

```

I am trying to add a `UPhysicsHandleComponent` variable which requires including `"PhysicsEngine/PhysicsHandleComponent.h"`. When I add the include at the top, it breaks the UCLASS macro and says that the _declaration has not storage class or type specifier_.

```
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"

```

I’m not sure how to format the include so it fits with the IWYU specification.

---

<div class="post-metadata">

**Author:** ![phil\_me\_up](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@phil\_me\_up](https://forums.unrealengine.com/u/phil_me_up)\
**Post date:** [June 8, 2018, 6:03pm UTC](https://forums.unrealengine.com/t/class-definition-breaks-after-adding-include/426916/2 "2018-06-08T18:03:16Z")

</div>

I’m not sure why that would break it, but I would say that you probably don’t need to include this in your header file. The usual way is to include it within your .cpp file, and in the .h you declare the variable with forward declaration

i.e. you put class in front of the variable like this:

```
class UPhysicsHandleComponent* MyComponent

```

or you declare the class at the top of your .h file:

```
//includes here

class UPhysicsHandleComponent;

UCLASS(....)
....

```

This basically tells the compiler that ‘I have a class called UPhysicsHandlerComponent’, so consider that an acceptable type for now and we’ll get the actual class definition later in the compilation process.

---

<div class="post-metadata">

**Author:** ![Dexgecko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dexgecko](https://forums.unrealengine.com/u/Dexgecko)\
**Post date:** [June 23, 2018, 8:29pm UTC](https://forums.unrealengine.com/t/class-definition-breaks-after-adding-include/426916/3 "2018-06-23T20:29:48Z")

</div>

I found that running project → rescan solution will often clear up these issues between the compiler and Unreal. I’m still confused as to which #includes to place where. Usually I include any class that is used by a predeclared variable at the top of the header file, but before the generated.h. Any class used by variables declared only in the cpp, goes at the top of the cpp file, but after the #include .h

Are those steps correct?
