Why is the latest Windows 10 WDK (10.1.17134.1) not compatible with the MSVC C++ strict string (/Zc:strictStrings) option? RRS feed

  • Question

  • The C++ compiler in Visual Studio 2017 provides an option to enable strict string handling. Strings that are read-only cannot be converted to char*, but only to const char*. This is an useful feature for fixed character strings that are placed in the read-only segment of the application or driver. It allows the compiler to detect bad usage of these strings during compile time.

    It seems however that the WDK (and it's included WDM framework) is not compatible with this option. A couple of macros and API are defined to use PSTR parameters instead of PCSTR or PVOID (void *) instead of const void*. For example:

        _In_ PVOID FailedAssertion,
        _In_ PVOID FileName,
        _In_ ULONG LineNumber,
        _In_opt_ PSTR Message


    It seems to me that these API calls could just take const char* / const void * as parameter, as the actual pointer that is passed in is a const char *.

    Friday, June 15, 2018 8:29 AM

All replies

  • Initially I cannot repro your issue, until I change the file type from .c to .cpp, and now it repro.

    So yes, I can confirm it is an issue when compiling the code as C++ files.

    But I do not have insight on clean up VS/SDK/WDK header files to be conformant to the latest C/C++ standard. These API have been there for years. Once published, it is really hard to make change to function signature or structure definition, for compatibility concerns.

    Friday, June 15, 2018 9:16 PM