Noob c++ question

Hello, I’m not quite familiar with C++.
I’m trying to implement basic structures for my strategy game and I’m getting this error.
The command ““C:\Program Files\Epic Games\UE_5.2\Engine\Build\BatchFiles\Build.bat” … -WaitMutex -FromMsBuild” exited with code 6.
my code:
StrategyStateManager.h



#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "StrategyStateManager.generated.h"


UCLASS()
class CTEST_API UStrategyStateManager : public UObject
{
    GENERATED_BODY()

public:
    UStrategyStateManager();

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "States")
        TArray<TSoftObjectPtr<class UStrategyStateData>> StateReferences;
};

StrategyStateManager.cpp

#include "StrategyStateManager.h"
#include "StrategyStateData.h" 

UStrategyStateManager::UStrategyStateManager()
{
    //  implementation
}

UStrategyStateData.h

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"

#include "UStrategyStateData.generated.h"


UCLASS()
class CTEST_API UStrategyStateData : public UObject
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, Category = "State Data")
        bool bIsPlayerControlled;

    UPROPERTY(EditAnywhere, Category = "State Data")
        int Resources;

    
};

UStrategyStateData.cpp

#include "UStrategyStateData.h"

UStrategyStateData::UStrategyStateData()
{
    //  implementation
}

Hey, your code snippets are a little unreadable due to the formatting.
Wrap the code between 3 backticks (3 at the start and 3 at the end, it’s the key to the left of the 1 key on the top row of numbers) and it’ll format it so it’s readable.

Make sure you’ve spelt class names correctly or not using the incorrect operator for something. If you check your Output Log in Visual Studio (or whatever IDE you’re using), there might be another issue that’s caught before this.

Thanks for the formatting advice! there is only one error in log

Out of interest, try disabling LIVE coding, or compiling from either the Editor itself or your IDE. Not an error I’m familiar with I’m afraid.

interesting… after disabling live coding i have 3 erorrs:
C1083 Cannot open include file: ‘StrategyStateData.h’: No such file or directory C:\Users\Admin\Documents\Unreal Projects\ctest\Source\ctest\StrategyStateManager.cpp

C2511|‘UStrategyStateData::UStrategyStateData(void)’: overloaded member function not found in ‘UStrategyStateData’|ctest|C:\Users\Admin\Documents\Unreal Projects\ctest\Source\ctest\UStrategyStateData.cpp
and the old one
MSB3073|The command C:\Program Files\Epic Games\UE_5.2\Engine\Build\BatchFiles\Build.bat ctestEditor Win64 Development -Project=C:\Users\Admin\Documents\Unreal Projects\ctest\ctest.uproject -WaitMutex -FromMsBuild exited with code 6.|ctest|C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets|44||

anyway, i was interested if my syntax is right, so now i should dig into something else… Thank you for help

Ok, so solution was to disable then enable live coding, then restart after that compiler showed proper information.

This error is a common thing, and it’s not a real issue.
It happens because you try to recompile your project via Visual Studio, while Editor is already running.

This will indeed not happen, if you haven’t used the Live Coding, but in this case you would have to reset the Editor every time after making any code change.

Instead, you should actually use the Live Coding feature to re-compile any code change.
You can do this by pressing this button (bottom-right corner of screen):

or by pressing: Ctrl+Alt+F11

Actually, compilation output log should have told you about this:

Unable to build while Live Coding is active. Exit the editor and game, or press Ctrl+Alt+F11 if iterating on code in the editor or game
1 Like

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