diff --git a/README.md b/README.md index e1b1e6f..1688ed5 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[ - **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs - **[@ximion](https://github.com/ximion)** - Added support for installation with meson - **[@whiterabbit963](https://github.com/whiterabbit963)** - Fixed a bug with value_or conversions - +- **[@beastle9end](https://github.com/beastle9end)** - Made Windows.h include bypass
# Contact diff --git a/include/toml++/toml_default_formatter.hpp b/include/toml++/toml_default_formatter.hpp index b739425..91b4e91 100644 --- a/include/toml++/toml_default_formatter.hpp +++ b/include/toml++/toml_default_formatter.hpp @@ -204,9 +204,16 @@ TOML_NAMESPACE_END; // implementations of windows wide string nonsense #if TOML_WINDOWS_COMPAT -TOML_DISABLE_WARNINGS; -#include // fuckkkk :( -TOML_ENABLE_WARNINGS; +namespace winapi +{ + extern "C" + { + int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, const wchar_t* lpWideCharStr, int cchWideChar, + const char* lpMultiByteStr, int cbMultiByte, const char* lpDefaultChar, int* lpUsedDefaultChar); + int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char* lpMultiByteStr, int cbMultiByte, + const wchar_t* lpWideCharStr, int cchWideChar); + } +} TOML_IMPL_NAMESPACE_START { @@ -218,13 +225,13 @@ TOML_IMPL_NAMESPACE_START return {}; std::string s; - const auto len = WideCharToMultiByte( + const auto len = winapi::WideCharToMultiByte( 65001, 0, str.data(), static_cast(str.length()), nullptr, 0, nullptr, nullptr ); if (len) { s.resize(static_cast(len)); - WideCharToMultiByte(65001, 0, str.data(), static_cast(str.length()), s.data(), len, nullptr, nullptr); + winapi::WideCharToMultiByte(65001, 0, str.data(), static_cast(str.length()), s.data(), len, nullptr, nullptr); } return s; } @@ -237,11 +244,11 @@ TOML_IMPL_NAMESPACE_START return {}; std::wstring s; - const auto len = MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), nullptr, 0); + const auto len = winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), nullptr, 0); if (len) { s.resize(static_cast(len)); - MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), s.data(), len); + winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), s.data(), len); } return s; } diff --git a/toml.hpp b/toml.hpp index c026e3e..e042719 100644 --- a/toml.hpp +++ b/toml.hpp @@ -11963,9 +11963,16 @@ TOML_NAMESPACE_END; // implementations of windows wide string nonsense #if TOML_WINDOWS_COMPAT -TOML_DISABLE_WARNINGS; -#include // fuckkkk :( -TOML_ENABLE_WARNINGS; +namespace winapi +{ + extern "C" + { + int __stdcall WideCharToMultiByte(unsigned int CodePage, unsigned long dwFlags, const wchar_t* lpWideCharStr, int cchWideChar, + const char* lpMultiByteStr, int cbMultiByte, const char* lpDefaultChar, int* lpUsedDefaultChar); + int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char* lpMultiByteStr, int cbMultiByte, + const wchar_t* lpWideCharStr, int cchWideChar); + } +} TOML_IMPL_NAMESPACE_START { @@ -11977,13 +11984,13 @@ TOML_IMPL_NAMESPACE_START return {}; std::string s; - const auto len = WideCharToMultiByte( + const auto len = winapi::WideCharToMultiByte( 65001, 0, str.data(), static_cast(str.length()), nullptr, 0, nullptr, nullptr ); if (len) { s.resize(static_cast(len)); - WideCharToMultiByte(65001, 0, str.data(), static_cast(str.length()), s.data(), len, nullptr, nullptr); + winapi::WideCharToMultiByte(65001, 0, str.data(), static_cast(str.length()), s.data(), len, nullptr, nullptr); } return s; } @@ -11996,11 +12003,11 @@ TOML_IMPL_NAMESPACE_START return {}; std::wstring s; - const auto len = MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), nullptr, 0); + const auto len = winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), nullptr, 0); if (len) { s.resize(static_cast(len)); - MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), s.data(), len); + winapi::MultiByteToWideChar(65001, 0, str.data(), static_cast(str.length()), s.data(), len); } return s; }