# Circular dependency bug on interface?

**URL:** <https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187>\
**Category:** C++\
**Tags:** dependencies, unreal-engine, CPP, question\
**Created:** [December 5, 2022, 10:39pm UTC](https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187 "2022-12-05T22:39:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doc.gdi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Doc.gdi](https://forums.unrealengine.com/u/Doc.gdi)\
**Post date:** [December 5, 2022, 10:39pm UTC](https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187/1 "2022-12-05T22:39:30Z")

</div>

Hello all.  
I was trying to make any mesh to play videos. With a solver to hold all media players, textures and so on. And all right, even the interface works well until I tried to create a function in the interface that returns a Array with a struct created on other header file. Then it throws that error warning of a circular dependency even when im using foward declaration

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/7/227396d3aedc8e1395153cd06edaaa3c897f9511.png)

I really ran out of ideas

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [December 5, 2022, 10:57pm UTC](https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187/2 "2022-12-05T22:57:54Z")

</div>

> [@Forward Declare Structs???](https://forums.unrealengine.com/t/forward-declare-structs/115559/5):
>
> You can’t forward declare a struct that is used as a non-pointer (since the size of the struct must be known at compile time) and you cannot tag a struct pointer as UPROPERTY, so you must put that struct on a .h file and include it in your header.

---

<div class="post-metadata">

**Author:** ![Doc.gdi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Doc.gdi](https://forums.unrealengine.com/u/Doc.gdi)\
**Post date:** [December 6, 2022, 2:38pm UTC](https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187/3 "2022-12-06T14:38:09Z")

</div>

If I didn’t get you wrong this is what you suggested

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/9/33987c0efc6374aba37e7bb5351d5315c443480d.png)

But it still complaining about foward declaration. I’ll copy here the code of the .h in case is needed to acces more easy

---

<div class="post-metadata">

**Author:** ![Doc.gdi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Doc.gdi](https://forums.unrealengine.com/u/Doc.gdi)\
**Post date:** [December 6, 2022, 2:38pm UTC](https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187/4 "2022-12-06T14:38:24Z")

</div>

The code is

VideoMeshSolver.h:

> #pragma once
> 
> #include “CoreMinimal.h”  
> #include “MediaPlayer.h”  
> #include “MediaTexture.h”  
> //#include “VideoMeshInterface.h” //include the interface  
> #include “GameFramework/Actor.h”  
> #include “Kismet/GameplayStatics.h”  
> #include “VideoMeshSolver.generated.h”
> 
> USTRUCT(BlueprintType) //STRUCT  
> struct FVideoSettings  
> {  
> GENERATED\_BODY()  
> //variables and stuff  
> };
> 
> UCLASS()  
> class VIDEOMESH\_API AVideoMeshSolver : public AActor, public IVideoMeshInterface  
> {  
> GENERATED\_BODY()  
> //variables and stuff  
> }

VideoMeshInterface.h:

> #pragma once
> 
> #include “CoreMinimal.h”  
> #include “UObject/Interface.h”  
> #include “VideoMeshSolver.h” //include the class with the struct  
> #include “VideoMeshInterface.generated.h”
> 
> // This class does not need to be modified.  
> UINTERFACE(MinimalAPI)  
> class UVideoMeshInterface : public UInterface  
> {  
> GENERATED\_BODY()  
> };
> 
> class VIDEOMESH\_API IVideoMeshInterface  
> {  
> GENERATED\_BODY()
> 
> UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Video)  
> TArray getSettings();
> 
> }

VideoMeshComponent.h:

> #pragma once
> 
> #include “CoreMinimal.h”  
> #include “Components/SkeletalMeshComponent.h”  
> #include “VideoMeshInterface.h”  
> #include “VideoMeshSolver.h” //include the class and struct  
> #include “VideoSkeletalMeshComponent.generated.h”
> 
> UCLASS(ClassGroup = Rendering, meta = (BlueprintSpawnableComponent))  
> class VIDEOMESH\_API UVideoSkeletalMeshComponent : public USkeletalMeshComponent, public IVideoMeshInterface  
> {  
> GENERATED\_BODY()  
> //variables and stuff  
> }

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [December 6, 2022, 3:17pm UTC](https://forums.unrealengine.com/t/circular-dependency-bug-on-interface/722187/5 "2022-12-06T15:17:15Z")

</div>

Sorry for the delay the copied code pasted the wrong quotation marks and was spewing out compile errors.

Swapped out the \_API for my project just replace it with your own.

VideoMeshInterface.h

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/Interface.h"
//#include "VideoMeshSolver.h" //include the class with the struct
#include "VideoMeshInterface.generated.h"

// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UVideoMeshInterface : public UInterface
{
GENERATED_BODY()
};

class CIRCLEDEP_API IVideoMeshInterface
{
    GENERATED_BODY()
public:
    //UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Video)
        TArray<struct FVideoSettings> getSettings();
};

```

VideoMeshSolver.h

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "MediaPlayer.h"
#include "MediaTexture.h"
#include "VideoMeshInterface.h" //include the interface
#include "GameFramework/Actor.h"
#include "Kismet/GameplayStatics.h"
#include "VideoMeshSolver.generated.h"

USTRUCT(BlueprintType) //STRUCT
struct FVideoSettings
{
GENERATED_BODY()
//variables and stuff
};

UCLASS()
    class CIRCLEDEP_API AVideoMeshSolver : public AActor, public IVideoMeshInterface
{
    GENERATED_BODY()
        //variables and stuff
        TArray<FVideoSettings> getSettings();
};

```

VideoSkeletalMeshComponent.h

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/SkeletalMeshComponent.h"
#include "VideoMeshInterface.h"
#include "VideoMeshSolver.h" //include the class and struct
#include "VideoSkeletalMeshComponent.generated.h"

UCLASS(ClassGroup = Rendering, meta = (BlueprintSpawnableComponent))
class CIRCLEDEP_API UVideoSkeletalMeshComponent : public USkeletalMeshComponent, public IVideoMeshInterface
{
GENERATED_BODY()
    //variables and stuff
    TArray<FVideoSettings> getSettings();
};

```

For future projects it’s better to isolate the struct to it’s own file.
