taocpp / PEGTL

Parsing Expression Grammar Template Library
Boost Software License 1.0
1.94k stars 228 forks source link

CreateFile2 not available before Windows 8 #155

Closed matbech closed 5 years ago

matbech commented 5 years ago

In https://github.com/taocpp/json/blob/master/include/tao/json/external/pegtl/internal/file_mapper_win32.hpp#L76

CreateFile2 is not available before Windows 8: https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfile2

You may want to use something like:

#if (_WIN32_WINNT >= 0x0602)
 const auto handle = ::CreateFile2( ws.c_str(),
                                                    GENERIC_READ,
                                                    FILE_SHARE_READ,
                                                    OPEN_EXISTING,
                                                    nullptr );
#else
const auto handle = ::CreateFileW( ws.c_str(),
                                                    GENERIC_READ,
                                                    FILE_SHARE_READ,
                                                    nullptr,
                                                    OPEN_EXISTING,
                                                    FILE_ATTRIBUTE_NORMAL,
                                                    nullptr );
#endif 
d-frey commented 5 years ago

Thanks, I'll update the embedded PEGTL in taocpp/json soon.