Thursday, 4 June 2026

Flags for cl.exe

cl /EHs 

enable C++ EH (no SEH exceptions)

SEH (Structured Exception Handling) is a Windows-specific mechanism for handling system-level exceptions e.g. access violations or hardware faults, using __try, __except and __finally. It is not part of the C++ standard.

cl /EHc

extern "C" defaults to nothrow

Explanation: extern "C" tells the compiler to use C linkage (C-style symbol names, no name mangling), and by virtue of defaulting to "C mode" we don't have exceptions (the C ABI has no concept of exceptions). 

So extern "C" functions therefore  implicitly move from:

extern "C" void foo();

to:

extern "C" void foo() noexcept;

noexcept was introduced in C++11.

No comments: