SSPI header file - fatal error

While the diagnostic is clear about having to define one of SECURITY_WIN32, SECURITY_KERNEL, or SECURITY_MAC, it doesn't help much in determining which one to use and why. To my knowledge, none of those are officially documented in the MSDN, so the only source of information are the actual header files.

  • SECURITY_MAC: This symbol only ever appears in <sspi.h>, a file with a copyright notice of 1992-1999. Presumably, this symbol was introduced to support compiling for "Classic" Mac OS, back when MFC was still planned to be a cross-platform framework targeting both Windows and Mac. The symbol doesn't appear to be of any practical use today.

  • SECURITY_KERNEL: The most enlightening comment here is from <NTSecPKG.h>, reading // Can't use the windows.h def'ns in kernel mode.. That appears to indicate that the SECURITY_KERNEL symbol needs to be defined, when accessing the security package from a module running in kernel mode.

  • SECURITY_WIN32: There are no comments on this symbol throughout the entire Windows SDK at all. It seems plausible, that this symbol should be used when accessing the security API from a user-mode application.

Assuming all of the above are correct, the following guideline can be used in determining the symbol to define:

  • Define SECURITY_WIN32 when compiling a user-mode application.
  • Define SECURITY_KERNEL when compiling a kernel-mode module.
  • Never define the obsolete SECURITY_MAC preprocessor symbol.

Just add

#define SECURITY_WIN32 

before all includes