开发者

microsoft windows driver kit pure C try catch syntax?

In the Windows Driver Kit (WDK) there are some driver code samples written in pure C, but sprinkled with some try-catch-finally constructs. Does someone know their semantics ? Thank you microsoft for your great tools and standards compliance.

Code extract from some_file.c:

try {
    ...
    if (!NT_SUCCESS( status )) {

       leave; // ???
    }
    ...
} finally {
 开发者_JS百科   ...
}

try  {
    ...
} except( EXCEPTION_EXECUTE_HANDLER ) {
    ...
}


The try/except handling in the WDK follows the SEH model used throughout windows. Notice that you can continue after catching an exception.

This model predated C++, so the C++ standard is not the same as the exception model used by Win32.

PS: C does not have exception handling, so SEH is a non-standard extension to C.

SEH exception handling in the MSDN

Introduction to SEH


Despite looking like C++ keywords, those are actually macros for SEH exception handling.

Add these do your preprocessor definitions:

try=__try
except=__except
finally=__finally
leave=__leave
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜