cwindowsdriverwdk

Why could DDK successfully compile an invalid source file?


First, you can successfully compile the following main.c through DDK build utility.

#include <ntddk.h>

NTSTATUS DriverEntry(PDRIVER_OBJECT, PUNICODE_STRING)
{
    try
    {
        leave;
    }
    except (1)
    {
    }

    return 0;
}

And however, please note that:

Both of "leave" and "except" are not valid C-language kerwords.

I know both of __leave and __except (i.e. with double leading underscores) are microsoft-specific keywords to extend the C language, but "leave" and "except" not.

I also confirmed that "leave" and "except" are not defined by macro. MSDN explains none about this.

Who can give me an explanation?


Solution

  • As Rohan noted, they are defined by macro in warning.h. The definitions are there for backward compatibility with old code which used the non-underscore versions.