Friday, 12 June 2009

NT_ERROR, NT_SUCCESS - identifier not found

After upgrading the Windows SDK I ran into the following compile error, in code which previous to the upgrade compiled without any problems:
error C3861: 'NT_ERROR': identifier not found'
error C3861: 'NT_SUCCESS': identifier not found
'
Turns out that the NT_SUCCESS macro definition has been moved from <stierr.h> to <subauth.h>. NT_ERROR seems to be completely removed from the headers in the new platform SDK.

To solve the problem I created this tiny header file which should work with both the new and old SDK:

#ifndef WINDOWS_NTSTATUS_H
#define WINDOWS_NTSTATUS_H

/**
* @author Roger Karlsson
* @since 2009-03-13
*/

#ifndef NT_SUCCESS
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
#endif

#ifndef NT_ERROR
#define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
#endif

#endif //WINDOWS_NTSTATUS_H

1 comment:

  1. I know this is an old post, but I am working on a WIN32 project that uses Bcrypt and I've stumbled upon this problem.

    Thanks for the useful information!

    ReplyDelete