# C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc

**URL:** <https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643>\
**Category:** Platform & Builds\
**Tags:** exception, unreal-engine, packaging-projects, CPP, question\
**Created:** [December 16, 2015, 6:44pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643 "2015-12-16T18:44:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [December 16, 2015, 6:44pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/1 "2015-12-16T18:44:31Z")

</div>

I’m getting the following build error when I’m trying to package my game:

```
Error C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc

```

These errors originate from the Boost library that I’m trying to build with my project, and the errors happen everywhere that they use their “BOOST\_SYSTEM\_NOEXCEPT” macro. These errors only occur when packaging, if I build in Development\_Editor I don’t see these errors.

Is there a way I can fix these errors? How can I specify the /EHsc flag?

**NOTE:** Answers below will depend heavily on engine version, try many of them before you give up!

---

<div class="post-metadata">

**Author:** ![rabellogp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rabellogp](https://forums.unrealengine.com/u/rabellogp)\
**Post date:** [December 27, 2015, 12:51pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/2 "2015-12-27T12:51:47Z")

</div>

Did you find a solution yet? I’m also getting the same error here, can’t find a way out…

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [December 28, 2015, 9:14pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/3 "2015-12-28T21:14:40Z")

</div>

I fixed this by adding

```
UEBuildConfiguration.bForceEnableExceptions = true;

```

To my build.cs file.

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [December 28, 2015, 9:14pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/4 "2015-12-28T21:14:58Z")

</div>

yep, check my answer below

---

<div class="post-metadata">

**Author:** ![Bumbala](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bumbala](https://forums.unrealengine.com/u/Bumbala)\
**Post date:** [January 13, 2016, 8:32pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/5 "2016-01-13T20:32:25Z")

</div>

Thanks this saved my day.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_590cb5931](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_590cb5931](https://forums.unrealengine.com/u/anonymous_user_590cb5931)\
**Post date:** [August 10, 2016, 5:03pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/6 "2016-08-10T17:03:28Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_3580a01d](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_3580a01d](https://forums.unrealengine.com/u/anonymous_user_3580a01d)\
**Post date:** [August 10, 2017, 8:29am UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/7 "2017-08-10T08:29:45Z")

</div>

I think the better solution here is to add the following to your build.cs file:

```
Definitions.Add("BOOST_SYSTEM_NOEXCEPT");

```

So that Boost will not insert “noexcept” everywhere, that way you don’t have to force enable exceptions for all modules.

---

<div class="post-metadata">

**Author:** ![Iohoilpotere](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Iohoilpotere](https://forums.unrealengine.com/u/Iohoilpotere)\
**Post date:** [January 26, 2018, 3:24pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/8 "2018-01-26T15:24:46Z")

</div>

Hi,

what if i have a bp project and not a c++ project? Where would i find build.cs? Please, i’m trying to package with a plugin which implements boost,

Thank you!

---

<div class="post-metadata">

**Author:** ![TTimo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TTimo](https://forums.unrealengine.com/u/TTimo)\
**Post date:** [February 26, 2018, 5:34pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/9 "2018-02-26T17:34:20Z")

</div>

This is readonly now (4.17), so it can’t be done this way anymore. I followed RCL’s suggestion of hacking out UnrealBuildTool.exe instead, see [How can I enable unwind semantics for C++-style exceptions? - Programming & Scripting - Unreal Engine Forums](https://answers.unrealengine.com/questions/51798/how-can-i-enable-unwind-semantics-for-c-style-exce.html)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_bed5619a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_bed5619a](https://forums.unrealengine.com/u/anonymous_user_bed5619a)\
**Post date:** [March 15, 2018, 12:00am UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/10 "2018-03-15T00:00:40Z")

</div>

For Unreal 4.18 in the [ProjectName].Build.cs file, the constructor parameter is now ReadOnlyTarget rules and I got an error using: bForceEnableExceptions = true;  
I made it work by editing [ProjectName].Target.cs in the directory above. Adding bForceEnableExceptions = true; there fixed my build so I could use exceptions.

---

<div class="post-metadata">

**Author:** ![Zeetu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Zeetu](https://forums.unrealengine.com/u/Zeetu)\
**Post date:** [May 10, 2018, 1:05am UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/11 "2018-05-10T01:05:33Z")

</div>

I had the same error but for the WFMedia module ONLY for client builds. What I did was added:

```
bEnableExceptions = true;

```

Into the Build file for that module only when building for windows. This fixed the build.

---

<div class="post-metadata">

**Author:** ![FortsFury](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FortsFury](https://forums.unrealengine.com/u/FortsFury)\
**Post date:** [May 16, 2018, 3:46pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/12 "2018-05-16T15:46:57Z")

</div>

Thank you!!! I’ve rebuilt several times and even tried disabling the WFMedia plugin… no idea why it’s throwing build errors about that.

---

<div class="post-metadata">

**Author:** ![poke1103](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@poke1103](https://forums.unrealengine.com/u/poke1103)\
**Post date:** [May 27, 2018, 1:43pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/13 "2018-05-27T13:43:12Z")

</div>

This doesn’t help at all.

---

<div class="post-metadata">

**Author:** ![kaitorched](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kaitorched](https://forums.unrealengine.com/u/kaitorched)\
**Post date:** [June 4, 2018, 5:28pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/14 "2018-06-04T17:28:57Z")

</div>

Strangely this didn’t work for me on 4.19. I just removed the WFMedia plugin folder and now it builds though.

---

<div class="post-metadata">

**Author:** ![Samlsewall](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samlsewall](https://forums.unrealengine.com/u/Samlsewall)\
**Post date:** [June 15, 2018, 5:47pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/15 "2018-06-15T17:47:07Z")

</div>

In 4.19.2 none of the above answers will fix this issue if you build in shipping mode on Visual Studios 17.

In order to fix this, you must add a line to Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs inside the function AppendCLArguments\_Global:

```
        Arguments.Add("/EHsc");

```

This line will handle the compiler exception and you should be good to go! 😃

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c9e426b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c9e426b6](https://forums.unrealengine.com/u/anonymous_user_c9e426b6)\
**Post date:** [June 15, 2018, 9:31pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/16 "2018-06-15T21:31:36Z")

</div>

In 4.19.2, the probably best way to do this is in the `MyProject.Build.cs` file, just by adding `bEnableExceptions = true;`.  
But yea it is completely non-obvious and it took me hours to find a solution that works… But I think this is the one to go, as no global toolchain files have to be modified.

```
using UnrealBuildTool;
public class MyProject : ModuleRules
{
public MyProject(ReadOnlyTargetRules Target) : base(Target)
{
	PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
            bEnableExceptions = true; // Add this...

    PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });
}
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c9e426b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c9e426b6](https://forums.unrealengine.com/u/anonymous_user_c9e426b6)\
**Post date:** [June 15, 2018, 9:32pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/17 "2018-06-15T21:32:17Z")

</div>

Actually, the solution is slightly easier and you don’t need to modify the global toolchain file. See my answer below.

---

<div class="post-metadata">

**Author:** ![Samlsewall](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samlsewall](https://forums.unrealengine.com/u/Samlsewall)\
**Post date:** [June 15, 2018, 9:47pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/18 "2018-06-15T21:47:25Z")

</div>

Funny you should mention that. I tried that. It doesn’t work in 4.19.2 when you have visual studios 2017. 😕 Hence the adding of the compiler argument into the toolchain.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_c9e426b6](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_c9e426b6](https://forums.unrealengine.com/u/anonymous_user_c9e426b6)\
**Post date:** [June 15, 2018, 9:57pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/19 "2018-06-15T21:57:06Z")

</div>

I have VS 2017 of course! So it’s weird that this doesn’t work for you?

---

<div class="post-metadata">

**Author:** ![Samlsewall](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Samlsewall](https://forums.unrealengine.com/u/Samlsewall)\
**Post date:** [June 15, 2018, 10:00pm UTC](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643/20 "2018-06-15T22:00:26Z")

</div>

Odd! Have you tried running a shipping build? Because your solution works fine until you build shipping, at which point it produces the error.

[Next page](https://forums.unrealengine.com/t/c4577-noexcept-used-with-no-exception-handling-mode-specified-termination-on-exception-is-not-guaranteed-specify-ehsc/341643.md?page=2)
