MeeSong / KTL

Windows Kernel Template Library
MIT License
108 stars 41 forks source link

Build error with KTL #1

Open JonCavesMSFT opened 5 years ago

JonCavesMSFT commented 5 years ago

Hi: we have recently updated the Microsoft Visual C++ compiler to give an error if a template parameter is shadowed by a function parameter - previous versions of the compiler did not detect this error, which, in some cases led to a compiler crash. Unfortunately KTL is failing to build with the new compiler because it appears to reference an old (very old?) version of the Windows SDK (and hence the CRT). If we use a new compiler we are seeing the following error:

D:\CoreXTCache\Microsoft.WindowsAzure.DirectDrive.External.Windows.sdk.10.0.14296\inc\crt\wchar.h(642): error C7576: declaration of '_Size' shadows a template parameter D:\CoreXTCache\Microsoft.WindowsAzure.DirectDrive.External.Windows.sdk.10.0.14296\inc\crt\wchar.h(642): note: see declaration of '_Size'

This is due to this function declaration:

errno_t __cdecl _cgetws_s(wchar_t* _Buffer, size_t _SizeInWords, size_t* _SizeRead);

extern "C++"
{
        template<size_t _Size>
    inline errno_t __cdecl _cgetws_s(wchar_t (&_Buffer)[_Size], size_t* _Size)
    {
        return _cgetws_s(_Buffer, _Size, _Size);
    }
}

The definition of _cgetws_s should be:

        template<size_t _Size>
    inline errno_t __cdecl _cgetws_s(wchar_t (&_Buffer)[_Size], size_t* _SizeRead)
    {
        return _cgetws_s(_Buffer, _Size, _SizeRead);
    }

and this is what newer versions of the SDK (and hence the Unified CRT) include.

Thanks Jonathan Caves

loneicewolf commented 3 years ago

@JonCavesMSFT Thanks for the info!