Thanks gentlemen.
As I played with the options, I did find that the compiler is already giving a warning for this : warning C4535: calling _set_se_translator() requires /EHa
I looked to see if that was an attribute or decorator on the function in the VS headers so I could transplant it directly in my code, but could not find anything.
So far, I have thus settled on adding a comment in the code for other developers to see when the warning is given.
// Save & Restore the Structured Exception Handler
// Set our own handler during the call
class Scoped_SE_Translator
{
private:
const _se_translator_function old_SE_translator;
public:
Scoped_SE_Translator() = delete;
Scoped_SE_Translator(_se_translator_function new_SE_translator) noexcept : // NOTE: Compiler option /EHa is required ("Enable C++ Exception" = "Yes with SEH Exceptions")
old_SE_translator{_set_se_translator(new_SE_translator)} { }
~Scoped_SE_Translator() noexcept { _set_se_translator(old_SE_translator); }
};
I also set up project defaults in my existing solution.props file:
<ItemDefinitionGroup>
<ClCompile>
<ExceptionHandling>Async</ExceptionHandling>
<FloatingPointExceptions>true</FloatingPointExceptions>
<TreatSpecificWarningsAsErrors>4535;%(TreatSpecificWarningsAsErrors)</TreatSpecificWarningsAsErrors>
</ClCompile>
</ItemDefinitionGroup>
However, that depends on developers adding a line in new vcxproj files:
<Import Project="$(SolutionDir)SolutionSettings.props" />
I am not sure if there is a more 'forceful' way to ensure new projects have the 'correct' defaults.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…