'node-gyp build fails on C++ exception handling (warning C4530: C++ exception handler used, but unwind semantics are not enabled.) Want /EHsc

Trying to get node-gyp to build a trivial C++ Hello World program with added xxx() routine that uses try/catch/finally. Says I need to specify /EHsc but have tried and failed at all attempts. If I comment out the finally clause, it warns, builds and runs. With the finally clause in, it fails.

current attempt at binding.gyp:
{
  "targets": [
    {
      "target_name": "greet",
      "cflags!": [ "-fno-exceptions" ],
      "cflags_cc!": [ "-fno-exceptions" ],
      "sources": [
        "./src/greeting.cpp",
        "./src/index.cpp"
      ],
      
      "include_dirs": [
        "<!@(node -p \"require('node-addon-api').include\")"
      ],
      'conditions': [
         ['OS=="win"', {
                'VCCLCompilerTool': {
                        "AdditionalOptions": [
                        "/EHsc",
                        "/execution-charset:utf-8",
                        "/source-charset:utf-8",
                    ], 
                    'WarningLevel': 4,
                    'ExceptionHandling': 1,
                },
            'defines': [
              'WINDOWS_SPECIFIC_DEFINE',
            ],
          }],
        ],
      },
      ],
      'configurations': {
        'Release': {
          'msvs_settings': {
          'VCCLCompilerTool': {
            'ExceptionHandling': 1
            }
          }
        }
      }
    }
    


#include <string>
#include "greeting.h"

std::string hello( std::string name ) {
  return "Hello " + name + "!";
}

void xxx() {
  int i=1;
  i++;

  try {
    i++;
  }
  catch(...){
    i = -1;
  }
/*
  finally {
    i = -22;
  }
*/
}

Any hints, clues, or otherwise desperately appreciated. Thanks. --Tracy



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source