Merge pull request #16 from gmbeard/windows-unicode-compilation-fix

Windows unicode compilation fix
This commit is contained in:
mandreyel 2018-10-18 14:26:21 +02:00 committed by GitHub
commit e0ae329583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -56,6 +56,9 @@ int main()
```
However, mio does not check whether the provided file descriptor has the same access permissions as the desired mapping, so the mapping may fail. Such errors are reported via the `std::error_code` out parameter that is passed to the mapping function.
**WINDOWS USERS**: This library doesn't support the use of wide character
types for functions where character strings are expected (e.g. path parameters).
### Example
```c++
@ -249,6 +252,7 @@ cmake --build . --config Release --target install
```
Note that the last command of the installation sequence may require administrator privileges (e.g. `sudo`) if the installation root directory lies outside your home directory.
This installation
+ copies the mio header files to the `include/mio` subdirectory of the installation root
+ generates and copies several CMake configuration files to the `share/cmake/mio` subdirectory of the installation root

View File

@ -72,7 +72,7 @@ file_handle_type open_file(const String& path,
return INVALID_HANDLE_VALUE;
}
#ifdef _WIN32
const auto handle = ::CreateFile(c_str(path),
const auto handle = ::CreateFileA(c_str(path),
mode == access_mode::read ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,

View File

@ -2,6 +2,9 @@ add_executable(mio.test test.cpp)
target_link_libraries(mio.test PRIVATE mio::mio)
add_test(NAME mio.test COMMAND mio.test)
add_executable(mio.example example.cpp)
target_link_libraries(mio.example PRIVATE mio::mio)
add_test(NAME mio.example COMMAND mio.example)
if(WIN32)
add_executable(mio.unicode.test unicode_test.cpp)
target_link_libraries(mio.unicode.test PRIVATE mio::mio)
target_compile_definitions(mio.unicode.test PRIVATE UNICODE)
add_test(NAME mio.unicode.test COMMAND mio.test)
endif()