Correct header file order for using HID APIs

Found On: December 2009

Unlike the rest of the world, I got my hands on the Wii remote just recently. My brother bought it for me so that I could interface with its hacks available all around the web (Ref: So, I just installed Windows Driver Kit version 7600.16385.0. Strangly, even when I copied the code available over the internet, I had problems with the header files. No matter how much I tried, I kept on missing definitions such as __drv_IRQL, checkreturn etc. I had no idea what these were and I decided to investigate. Researching over the internet it seemed that driver kits available at around 2007 probably didn’t have this problem.

Turns out, the missing definitions are PREfast macros. PREfast helps to write kernel level drivers properly because one error in these drivers can halt the system. These macros helped PREfast to pinpoint some types of problems.

The following order of header file declaration seems to eliminate the problem:

#include <sal.h>
#include <sal_supp.h>
#include <driverspecs.h>
#include <windows.h>
#if defined(__cplusplus)
extern "C"
#include <hidsdi.h>
#if defined(__cplusplus)
#include <setupapi.h>

If there is a way to turn off the use of these macros, let me know in the comment below.


Leave a reply here, thanks!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s