Visual Studio C++ datatypes are undefined RRS feed

  • Question

  • I have a Visual Studio 2015 Community C++ Project which includes bcrypt.h:

    #include <bcrypt.h>

    I go to the definition, and this file is in:

    C:\Program Files (x86)\Windows Kits\8.1\Include\shared\bcrypt.h

    This include file causes many errors, saying identifiers like PUCHAR, ULONG, etc. are undefined.

    The VC++ Directories : Include Directories says :


    Which evaluates to

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
    C:\Program Files (x86)\Windows Kits\8.1\Include\um
    C:\Program Files (x86)\Windows Kits\8.1\Include\shared
    C:\Program Files (x86)\Windows Kits\8.1\Include\winrt

    I'm guessing the problem is some directories are in 8.1 and some are in 10, but I don't know how to change that. How can I fix this?

    Thursday, November 23, 2017 11:42 PM

All replies

  • Hi Acrym,

    Welcome to the MSDN forum.

    Since your issue is about the C++ development and our forum is to discuss the VS IDE, I will help you move this thread to the appropriate forum to get a better support, thank you for our understanding.

    Best regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, November 24, 2017 1:42 AM
  • This is perfectly fine if you are using the Windows 8.1 SDK in Visual Studio 2015 and 2017.

    Since the CRT was refactored starting with Visual Studio 2015 then Visual Studio 2015 doesn't have its own CRT, so it gets it from the Windows SDK. But the UCRT was only added in Windows 10 so there is a bit of a mix of directories.

    As long as um and shared come from the same SDK though, and individual headers come from the same SDK then everything will be fine. So you don't have to fix this (unless you want to lose access to everything in the C runtime).

    Also, the reason why bcrypt.h doesn't automatically pull in the required headers is probably because it is usable in kernel mode as well as user mode. This makes it easier to maintain this header because the way that you get the types in kernel mode is different to user mode. (In user mode you include Windows.h, in kernel mode then you would include Ntddk.h) So as was mentioned already, just include Windows.h before bcrypt.h and things should work.

    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Edited by Darran Rowe Friday, November 24, 2017 8:25 AM
    • Proposed as answer by Baron Bi Wednesday, November 29, 2017 2:18 AM
    Friday, November 24, 2017 8:16 AM