# New definition; multiple initialisation

**URL:** <https://forums.unrealengine.com/t/new-definition-multiple-initialisation/2230142>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [December 18, 2024, 10:57am UTC](https://forums.unrealengine.com/t/new-definition-multiple-initialisation/2230142 "2024-12-18T10:57:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ViaCognita](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/viacognita/32/906601_2.png) [@ViaCognita](https://forums.unrealengine.com/u/ViaCognita)\
**Post date:** [December 18, 2024, 10:57am UTC](https://forums.unrealengine.com/t/new-definition-multiple-initialisation/2230142/1 "2024-12-18T10:57:26Z")

</div>

Hey there!

I’ve just update a project from Unreal 5.4.4 to 5.5.1. When I’ve compiled it I’ve got the following error:

```auto
Error C2374 ‘NextFallingBlockSpawnLocation’: new definition; multiple initialisation C:\source\Tetris\Public\GameModeBase.h 14		
Error C2374 ‘NextBlockSampleSpawnLocation’: new definition; multiple initialisation C:\source\Tetris\Public\GameModeBase.h 15

```

I have two header files with these declarations.

In `TTetrisGameModeBase.h`:

```auto

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

#pragma once

#include "CoreMinimal.h"
#include "TUtils.h"
#include "GameFramework/GameModeBase.h"
#include "TTetrisGameModeBase.generated.h"

class ATFallingBlockActor;
class ATCheckLinesActor;

const FVector PuzzleToSolveSpawnLocation = FVector(0.0f, -500.0f, 850.0f);
const FVector NextFallingBlockSpawnLocation = FVector(0.0f, 25.0f, 1000.0f);
const FVector NextBlockSampleSpawnLocation = FVector(0.0f, -850.0f, 850.0f);

/**
 * 
 */
UCLASS()
class TETRIS_API ATTetrisGameModeBase : public AGameModeBase

```

And in `TProgrammingModeBase.h`:

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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "TProgrammingModeBase.generated.h"

enum class EInstruction : uint8;
class ATCheckLinesActor;
class ATFallingBlockActor;
enum class EBlockType : uint8;

const FVector NextFallingBlockSpawnLocation = FVector(0.0f, 25.0f, 1000.0f);
const FVector NextBlockSampleSpawnLocation = FVector(0.0f, -850.0f, 850.0f);
const FVector CreatedInstructionSpawnLocation = FVector(0.0f, -600.0f, 150.0f);

/**
 * 
 */
UCLASS()
class TETRIS_API ATProgrammingModeBase : public AGameModeBase

```

I don’t know why I’m getting these errors because these header files don’t reference each other.

Any idea?

Thanks.

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [December 18, 2024, 11:36am UTC](https://forums.unrealengine.com/t/new-definition-multiple-initialisation/2230142/2 "2024-12-18T11:36:11Z")

</div>

> [@ViaCognita](#):
>
> `NextFallingBlockSpawnLocation`

Hey,

This looks to be because you are defining 2 Global variables with the same name. You either want to change these so they arent named the same or change them not to be global and instead move them to be part of a class or namespace.

---

<div class="post-metadata">

**Author:** ![MagForceSeven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magforceseven/32/906563_2.png) [@MagForceSeven](https://forums.unrealengine.com/u/MagForceSeven)\
**Post date:** [December 18, 2024, 3:12pm UTC](https://forums.unrealengine.com/t/new-definition-multiple-initialisation/2230142/3 "2024-12-18T15:12:16Z")

</div>

As Jake-Simpson said, you have two variable declarations visible from the same scope.

Either you can just have the  
`const FVector XXX = FVector( ... );` in the header (leave it out of the cpp)

or you can extern a declaration in the header:  
`TETRIS_API extern const FVector XXX;`  
with the definition in the cpp:  
`const FVector XXX = FVector( … );

Lastly you could shift those variables to public static members of your game mode so that they don’t pollute the global namespace:

In the header:  
`static const FVector XXX;`  
In the cpp:  
`const FVector ATProgrammingModeBase::XXX = FVector( ... );`

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [January 17, 2025, 3:12pm UTC](https://forums.unrealengine.com/t/new-definition-multiple-initialisation/2230142/4 "2025-01-17T15:12:18Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
