How can I enable unwind semantics for C++-style exceptions?

need help,4.19

Since 4.19 the parameter is:

bEnableExceptions = true;

in build.cs

,

need help, There is no Projectname.build.cs file in 4.20

We are going to be moving our 4.19 project to 4.20 soon. I expect I will run into this when we get there… so +1 on this.

I’m in 4.21 and I do have it, so probably 4.20 has it too. You might be looking in the wrong place — it’s not in Source but in Source/YOURPROJECT together with your YOURPROJECT.h etc.

BTW tested this on 4.21 and it works.

This works! Thank you!

need help,4.21

Need 4.22 too

Did you have any clues since?

Why is this still a problem in UE5.0.1???

So the only way I could find to fix this is to edit the buildtools.

Open the buildtools .sln up in VS etc

You will find a folder called Configuration, look for BuildConfiguration.cs and add this to the bottom of it:


		/// <summary>Enable exceptions for all modules.</summary>
		[RequiresUniqueBuildEnvironment]
		public bool bForceEnableExceptions = true;

then have a look for the file TargetRules.cs where you can find the existing property bForceEnableExceptions which will be set to false. Change that to true and rebuild the solution.

Close UE editor down and open it back up - and with a whole lot of luck, the dog should compile for you again.

Another option are header-only libraries that use exceptions as the main error reporting mechanism. In that case, it’s annoying to not be able to use them.

I tried everything in this thread for a UE5 project and nothing worked. I don’t think this is possible in UE5.

I throw exception in my plugin and add bEnableExceptions = true; for it to work. This is my build.cs:

using UnrealBuildTool;

public class CharacterSelector_1 : ModuleRules
{
	public CharacterSelector_1(ReadOnlyTargetRules Target) : base(Target)
	{
        bEnableExceptions = true;

        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
		
		PublicDependencyModuleNames.AddRange(new string[]
		{
			"Core",
			"UMG",
            "CoreUObject",
            "Engine"
		});
	}
}
3 Likes

Taking the try/catch blocks out of my code worked for me.

This worked perfectly in UE5.3.

3 Likes