c++-winrtmidl

Cannot use [noexcept] in MIDL 3


In this year's Build Talk C++/WinRT 2.0: Faster and smarter in the open, Kenny Kerr demonstrates the use of the [noexcept] attribute in IDL, providing better optimization opportunities to the compiler by eliding exception handling at the ABI.

Trying this for myself, however, I ended up with MIDL compiler errors. The following stripped down IDL file

namespace NS
{
    interface IMyInterface
    {
        [noexcept] String DoStuff();
    };
}

produces the following diagnostic output:

error MIDL2025: [msg]syntax error [context]: expecting . near "]"
error MIDL2009: [msg]undefined symbol [context]: noexcept.String
error MIDL2025: [msg]syntax error [context]: expecting ] or , near "DoStuff"
error MIDL2025: [msg]syntax error [context]: expecting . near "("
error MIDL2026: [msg]cannot recover from earlier syntax errors; aborting compilation

Am I doing something wrong here, or is the [noexcept] attribute not yet available in the GA releases of Visual Studio (16.1.4) or the Windows SDK (10.0.18362.0)?


Solution

  • You'll need a newer version of MIDLRT. This feature is currently available in the insider builds of the Windows SDK and will ship with the next major update of Windows.