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

**URL:** <https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 4, 2014, 4:52am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934 "2014-06-04T04:52:29Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![anonymous\_user\_e41814541](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e41814541](https://forums.unrealengine.com/u/anonymous_user_e41814541)\
**Post date:** [June 14, 2018, 6:07am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/21 "2018-06-14T06:07:10Z")

</div>

need help,4.19

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_127df0b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_127df0b6](https://forums.unrealengine.com/u/anonymous_user_127df0b6)\
**Post date:** [June 25, 2018, 6:36am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/22 "2018-06-25T06:36:20Z")

</div>

Since 4.19 the parameter is:

```
bEnableExceptions = true;

```

in build.cs

,

---

<div class="post-metadata">

**Author:** ![jiangdengc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jiangdengc](https://forums.unrealengine.com/u/jiangdengc)\
**Post date:** [July 31, 2018, 5:55am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/23 "2018-07-31T05:55:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4ed6dbd41](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4ed6dbd41](https://forums.unrealengine.com/u/anonymous_user_4ed6dbd41)\
**Post date:** [October 6, 2018, 12:37am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/24 "2018-10-06T00:37:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Lalo\_Martins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lalo\_Martins](https://forums.unrealengine.com/u/Lalo_Martins)\
**Post date:** [February 3, 2019, 5:23am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/25 "2019-02-03T05:23:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mervpls](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mervpls](https://forums.unrealengine.com/u/mervpls)\
**Post date:** [July 8, 2019, 4:38am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/26 "2019-07-08T04:38:37Z")

</div>

This works! Thank you!

---

<div class="post-metadata">

**Author:** ![Xaser3D](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xaser3D](https://forums.unrealengine.com/u/Xaser3D)\
**Post date:** [October 17, 2019, 9:31am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/27 "2019-10-17T09:31:15Z")

</div>

need help,4.21

---

<div class="post-metadata">

**Author:** ![creatorue](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@creatorue](https://forums.unrealengine.com/u/creatorue)\
**Post date:** [July 27, 2020, 9:44am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/28 "2020-07-27T09:44:26Z")

</div>

Need 4.22 too

---

<div class="post-metadata">

**Author:** ![nansP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nansP](https://forums.unrealengine.com/u/nansP)\
**Post date:** [October 20, 2020, 7:04pm UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/29 "2020-10-20T19:04:24Z")

</div>

Did you have any clues since?

---

<div class="post-metadata">

**Author:** ![brennongwilliams](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brennongwilliams](https://forums.unrealengine.com/u/brennongwilliams)\
**Post date:** [May 8, 2022, 7:02am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/30 "2022-05-08T07:02:47Z")

</div>

> [@Elringus](#):
>
> `UEBuildConfiguration.bForceEnableExceptions = true;`

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d678166b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d678166b](https://forums.unrealengine.com/u/anonymous_user_d678166b)\
**Post date:** [May 8, 2022, 7:37am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/31 "2022-05-08T07:37:53Z")

</div>

> [@Elringus](#):
>
> bForceEnableExceptions

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:

```auto

		/// <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.

---

<div class="post-metadata">

**Author:** ![bgolinvaux](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@bgolinvaux](https://forums.unrealengine.com/u/bgolinvaux)\
**Post date:** [June 10, 2022, 12:12pm UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/32 "2022-06-10T12:12:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nick\_recursion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nick\_recursion](https://forums.unrealengine.com/u/nick_recursion)\
**Post date:** [October 30, 2022, 7:13pm UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/33 "2022-10-30T19:13:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [November 15, 2022, 8:38am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/34 "2022-11-15T08:38:00Z")

</div>

> [@anonymous\_user\_d678166b](#):
>
> buildtools .sln

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

```auto
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"
		});
	}
}

```

---

<div class="post-metadata">

**Author:** ![OberonElkins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OberonElkins](https://forums.unrealengine.com/u/OberonElkins)\
**Post date:** [October 2, 2023, 1:19pm UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/35 "2023-10-02T13:19:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tuatec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tuatec](https://forums.unrealengine.com/u/tuatec)\
**Post date:** [January 7, 2024, 6:36pm UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/36 "2024-01-07T18:36:01Z")

</div>

> [@lehuan5062](#):
>
> `bEnableExceptions = true;`

This worked perfectly in UE5.3.

---

<div class="post-metadata">

**Author:** ![windcrazy123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@windcrazy123](https://forums.unrealengine.com/u/windcrazy123)\
**Post date:** [July 24, 2024, 2:33am UTC](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934/37 "2024-07-24T02:33:28Z")

</div>

This worked perfectly in UE5.1.1. And I found this in the [source code](https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Programs/UnrealBuildTool/Configuration/ModuleRules.cs) at 886

```auto
/// <summary>
/// Enable exception handling
/// </summary>
public bool bEnableExceptions { get; set; }

```

[Previous page](https://forums.unrealengine.com/t/how-can-i-enable-unwind-semantics-for-c-style-exceptions/284934.md?page=1)
