From 63d3f7ade88aaeddaba8b8c469f601150403d2f2 Mon Sep 17 00:00:00 2001 From: josetr <37419832+josetr@users.noreply.github.com> Date: Sun, 13 Mar 2022 07:31:23 +0000 Subject: [PATCH] Add friendly option to enable exceptions --- src/CLI/Generator.cs | 2 +- src/Parser/ParserOptions.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CLI/Generator.cs b/src/CLI/Generator.cs index 5c6f72be..1489d2d5 100644 --- a/src/CLI/Generator.cs +++ b/src/CLI/Generator.cs @@ -150,7 +150,7 @@ namespace CppSharp } if (options.EnableExceptions) - parserOptions.AddArguments("-fcxx-exceptions"); + parserOptions.EnableExceptions = true; driverOptions.GenerateDebugOutput = options.Debug; driverOptions.CompileCode = options.Compile; diff --git a/src/Parser/ParserOptions.cs b/src/Parser/ParserOptions.cs index 41dffa66..6843aa15 100644 --- a/src/Parser/ParserOptions.cs +++ b/src/Parser/ParserOptions.cs @@ -86,6 +86,7 @@ namespace CppSharp.Parser TargetTriple.Contains("windows") || TargetTriple.Contains("msvc"); public bool EnableRTTI { get; set; } + public bool EnableExceptions { get; set; } public LanguageVersion? LanguageVersion { get; set; } public void BuildForSourceFile( @@ -367,6 +368,9 @@ namespace CppSharp.Parser if (!EnableRTTI) AddArguments("-fno-rtti"); + + if (EnableExceptions) + AddArguments("-fcxx-exceptions"); } public string BuiltinsDir