fix issues on different MinGW distro

This commit is contained in:
Jinhao 2017-07-07 08:34:34 +08:00
parent 57fe04119f
commit bd5e9fdc4a
6 changed files with 75 additions and 233 deletions

View File

@ -36,7 +36,7 @@
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
* - STD_FILESYSTEM_NOT_SUPPORTED (GCC < 5.3) ....
* - CXX_NO_INLINE_NAMESPACE (Visual C++ < 2015)
* - _enable_std_make_unique (GCC < 4.9)
* - _enable_std_make_unique (__cpluscplus < 201402)
* - _enable_std_put_time (GCC < 5)
* - _enable_std_clamp (Visual C++ < 2017)
*/
@ -118,13 +118,6 @@
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
//<codecvt> is a known issue on libstdc++, it works on libc++
#define STD_CODECVT_NOT_SUPPORTED
#if !defined(__cpp_lib_make_unique) || (__cpp_lib_make_unique != 201304)
#ifndef _enable_std_make_unique
#define _enable_std_make_unique
#endif
#endif
#endif
#elif defined(__GNUC__) //GCC
@ -149,20 +142,19 @@
# define _enable_std_put_time
# endif
#if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
# undef STD_FILESYSTEM_NOT_SUPPORTED
/// \todo define the namespace ????
#endif
# if ((__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3 ) ) )
# undef STD_FILESYSTEM_NOT_SUPPORTED
# endif
#if (__GNUC__ == 4)
#if ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1))
#define STD_THREAD_NOT_SUPPORTED
#endif
#if 0
#if (__GNUC_MINOR__ < 9)
#define _enable_std_make_unique
#endif
#endif
#if defined(NANA_MINGW)
#ifndef __MINGW64_VERSION_MAJOR
//It's a knonwn issue under MinGW(except MinGW-W64)
@ -191,8 +183,18 @@
# endif
#endif
//Detects the feature std::clamp
#include <iosfwd>
//Detects std::make_unique
#if (!defined(_MSC_VER)) && (__cplusplus < 201402L)
# if !defined(__cpp_lib_make_unique) || (__cpp_lib_make_unique != 201304)
# ifndef _enable_std_make_unique
# define _enable_std_make_unique
# endif
# endif
#endif
//Detects the feature std::clamp
//Visual C++ 2017 with /std:c++latest provides the std::clamp
#if !defined(_MSVC_LANG) || (_MSVC_LANG < 201403L)

View File

@ -22,9 +22,9 @@
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4099.html --- in html format
// http://article.gmane.org/gmane.comp.lib.boost.devel/256220 --- The filesystem TS unanimously approved by ISO.
// http://theboostcpplibraries.com/boost.filesystem --- Boost docs
// http://www.boost.org/doc/libs/1_58_0/libs/filesystem/doc/index.htm ---
// http://www.boost.org/doc/libs/1_58_0/libs/filesystem/doc/index.htm ---
// http://www.boost.org/doc/libs/1_34_0/libs/filesystem/doc/index.htm
// http://www.boost.org/doc/libs/1_58_0/boost/filesystem.hpp
// http://www.boost.org/doc/libs/1_58_0/boost/filesystem.hpp
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.200x --- Table 1.4. g++ C++ Technical Specifications Implementation Status
#ifndef NANA_FILESYSTEM_HPP
@ -46,10 +46,10 @@
#if (defined(NANA_FILESYSTEM_FORCE) || ( (defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(BOOST_FILESYSTEM_AVAILABLE)) && !(defined(BOOST_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_FORCE)) ) )
#undef NANA_USING_NANA_FILESYSTEM
#undef NANA_USING_NANA_FILESYSTEM
#define NANA_USING_NANA_FILESYSTEM 1
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) ))
#undef NANA_USING_BOOST_FILESYSTEM
#define NANA_USING_BOOST_FILESYSTEM 1
@ -65,14 +65,14 @@ namespace std {
} // std
#else
#undef NANA_USING_STD_FILESYSTEM
#define NANA_USING_STD_FILESYSTEM 1
# include <experimental/filesystem>
# undef NANA_USING_STD_FILESYSTEM
# define NANA_USING_STD_FILESYSTEM 1
# include <experimental/filesystem>
#endif
#ifndef __cpp_lib_experimental_filesystem
# define __cpp_lib_experimental_filesystem 1
# define __cpp_lib_experimental_filesystem 201406
#endif
#if NANA_USING_NANA_FILESYSTEM
@ -96,7 +96,7 @@ namespace nana { namespace experimental { namespace filesystem
#endif
enum class file_type
{
{
none = 0, ///< has not been determined or an error occurred while trying to determine
not_found = -1, ///< Pseudo-type: file was not found. Is not considered an error
regular = 1,
@ -108,11 +108,11 @@ namespace nana { namespace experimental { namespace filesystem
socket =7,
unknown= 8 ///< The file does exist, but is of an operating system dependent type not covered by any of the other
};
enum class perms
enum class perms
{
none = 0, ///< There are no permissions set for the file.
all = 0x1FF, ///< owner_all | group_all | others_all
all = 0x1FF, ///< owner_all | group_all | others_all
mask = 0xFFF, ///< all | set_uid | set_gid | sticky_bit.
unknown = 0xFFFF ///< not known, such as when a file_status object is created without specifying the permissions
};
@ -147,13 +147,13 @@ namespace nana { namespace experimental { namespace filesystem
file_type value_;
perms perms_;
};
/// concerned only with lexical and syntactic aspects and does not necessarily exist in
/// external storage, and the pathname is not necessarily valid for the current operating system
/// or for a particular file system
/// A sequence of elements that identify the location of a file within a filesystem.
/// external storage, and the pathname is not necessarily valid for the current operating system
/// or for a particular file system
/// A sequence of elements that identify the location of a file within a filesystem.
/// The elements are the:
/// rootname (opt), root-directory (opt), and an optional sequence of filenames.
/// rootname (opt), root-directory (opt), and an optional sequence of filenames.
/// The maximum number of elements in the sequence is operating system dependent.
class path
{
@ -177,7 +177,7 @@ namespace nana { namespace experimental { namespace filesystem
// modifiers
//void clear() noexcept;
path& make_preferred();
path& make_preferred();
path& remove_filename();
//path& replace_filename(const path& replacement);
//path& replace_extension(const path& replacement = path());
@ -188,13 +188,13 @@ namespace nana { namespace experimental { namespace filesystem
//path root_directory() const;
//path root_path() const;
//path relative_path() const;
path parent_path() const;
path filename() const;
path parent_path() const;
path filename() const;
//path stem() const;
path extension() const;
path extension() const;
// query
bool empty() const noexcept;
bool empty() const noexcept;
//bool has_root_name() const;
//bool has_root_directory() const;
//bool has_root_path() const;
@ -228,7 +228,7 @@ namespace nana { namespace experimental { namespace filesystem
//appends
path& operator/=(const path& other);
template<typename Source>
path& operator/=(const Source& source)
{
@ -265,8 +265,8 @@ namespace nana { namespace experimental { namespace filesystem
filesystem_error(const std::string& msg, const path& path1, std::error_code err);
filesystem_error(const std::string& msg, const path& path1, const path& path2, std::error_code err);
const path& path1() const noexcept;
const path& path2() const noexcept;
const path& path1() const noexcept;
const path& path2() const noexcept;
// const char* what() const noexcept;
private:
path path1_;
@ -307,8 +307,8 @@ namespace nana { namespace experimental { namespace filesystem
directory_iterator& operator++();
directory_iterator operator++(int); ///< extention
bool equal(const directory_iterator& x) const;
bool equal(const directory_iterator& x) const;
private:
template<typename Char>
static bool _m_ignore(const Char * p)
@ -330,12 +330,12 @@ namespace nana { namespace experimental { namespace filesystem
};
/// enable directory_iterator range-based for statements
inline directory_iterator begin( directory_iterator iter) noexcept
{
{
return iter;
}
inline directory_iterator end( const directory_iterator&) noexcept
{
{
return {};
}
@ -388,7 +388,7 @@ namespace nana { namespace experimental { namespace filesystem
if (is_directory(fs))
return (directory_iterator() == directory_iterator(p));
return (file_size(p) == 0);
}
// bool is_empty(const path& p, error_code& ec) noexcept;
@ -400,7 +400,7 @@ namespace nana { namespace experimental { namespace filesystem
//bool create_directory(const path& p, error_code& ec) noexcept;
bool create_directory(const path& p, const path& attributes);
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
/// The time of last data modification of p, determined as if by the value of the POSIX
/// stat structure member st_mtime obtained as if by POSIX stat().
@ -412,7 +412,7 @@ namespace nana { namespace experimental { namespace filesystem
path current_path();
//path current_path(error_code& ec);
void current_path(const path& p); ///< chdir
//void current_path(const path& p, error_code& ec) noexcept;
//void current_path(const path& p, error_code& ec) noexcept;
bool remove(const path& p);
bool remove(const path& p, std::error_code& ec); // noexcept;
@ -422,7 +422,7 @@ namespace nana { namespace experimental { namespace filesystem
template<typename CharType>
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
{
{
auto index = path.size();
if (index)

View File

@ -3,6 +3,11 @@
#include "../paint/truetype.hpp"
#ifdef NANA_WINDOWS
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
# include <windows.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////
@ -50,6 +55,19 @@ IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServiceP
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
#ifndef _WIN32_WINNT_WINXP
# define _WIN32_WINNT_WINXP 0x0501
#endif // _WIN32_WINNT_WINXP
#ifndef _WIN32_WINNT_VISTA
# define _WIN32_WINNT_VISTA 0x0600
#endif // _WIN32_WINNT_VISTA
#ifndef _WIN32_WINNT_WIN7
# define _WIN32_WINNT_WIN7 0x0601
#endif // _WIN32_WINNT_WIN7
VERSIONHELPERAPI
IsWindowsXPOrGreater()
{
@ -115,24 +133,10 @@ IsWindows8OrGreater()
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
}
#ifndef _WIN32_WINNT_WINBLUE // (0x0602)
#ifndef _WIN32_WINNT_WINBLUE // (0x0602)
#define _WIN32_WINNT_WINBLUE (0x0602)
#endif // _WIN32_WINNT_WINBLUE (0x0602)
VERSIONHELPERAPI
IsWindows8Point1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
}
VERSIONHELPERAPI
IsWindowsServer()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0, 0, VER_NT_WORKSTATION };
DWORDLONG const dwlConditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask);
}
#endif // NTDDI_VERSION
@ -398,11 +402,11 @@ namespace nana
{
if(0 == --(i->second))
fc.erase(i);
if(0 == fc.size())
::FcConfigAppFontClear(nullptr);
}
}
#endif
}
}
}

View File

@ -24,170 +24,6 @@
#include <shellapi.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////
/******************************************************************
* *
* VersionHelpers.h -- This module defines helper functions to *
* promote version check with proper *
* comparisons. *
* *
* Copyright (c) Microsoft Corp. All rights reserved. *
* *
******************************************************************/
#include <specstrings.h> // for _In_, etc.
#if !defined(__midl) && !defined(SORTPP_PASS)
#if (NTDDI_VERSION >= NTDDI_WINXP)
#ifdef __cplusplus
#define VERSIONHELPERAPI inline bool
#else // __cplusplus
#define VERSIONHELPERAPI FORCEINLINE BOOL
#endif // __cplusplus
VERSIONHELPERAPI
IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
DWORDLONG const dwlConditionMask = VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
osvi.dwMajorVersion = wMajorVersion;
osvi.dwMinorVersion = wMinorVersion;
osvi.wServicePackMajor = wServicePackMajor;
return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
}
VERSIONHELPERAPI
IsWindowsXPOrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
}
VERSIONHELPERAPI
IsWindowsXPSP1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
}
VERSIONHELPERAPI
IsWindowsXPSP2OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
}
VERSIONHELPERAPI
IsWindowsXPSP3OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
}
VERSIONHELPERAPI
IsWindowsVistaOrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
}
VERSIONHELPERAPI
IsWindowsVistaSP1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
}
VERSIONHELPERAPI
IsWindowsVistaSP2OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
}
VERSIONHELPERAPI
IsWindows7OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
}
VERSIONHELPERAPI
IsWindows7SP1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
}
#ifndef _WIN32_WINNT_WIN8 // (0x0602)
#define _WIN32_WINNT_WIN8 (0x0602)
#endif // _WIN32_WINNT_WIN8(0x0602)
VERSIONHELPERAPI
IsWindows8OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
}
#ifndef _WIN32_WINNT_WINBLUE // (0x0602)
#define _WIN32_WINNT_WINBLUE (0x0602)
#endif // _WIN32_WINNT_WINBLUE (0x0602)
VERSIONHELPERAPI
IsWindows8Point1OrGreater()
{
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
}
VERSIONHELPERAPI
IsWindowsServer()
{
OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0, 0, VER_NT_WORKSTATION };
DWORDLONG const dwlConditionMask = VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL);
return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask);
}
#endif // NTDDI_VERSION
#endif // defined(__midl)
////////////////////////////////////////////////////////////////////////////////////////////////////
//#if defined(_MSC_VER)
////#include <VersionHelpers.h>
//bool IsWindowsVistaOrGreater() { return false; }
//bool //VERSIONHELPERAPI
//IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor)
//{
// OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0,{ 0 }, 0, 0 };
// DWORDLONG const dwlConditionMask = VerSetConditionMask(
// VerSetConditionMask(
// VerSetConditionMask(
// 0, VER_MAJORVERSION, VER_GREATER_EQUAL),
// VER_MINORVERSION, VER_GREATER_EQUAL),
// VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
//
// osvi.dwMajorVersion = wMajorVersion;
// osvi.dwMinorVersion = wMinorVersion;
// osvi.wServicePackMajor = wServicePackMajor;
//
// return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
//}
//
//
//
//#endif // _MSVC
namespace nana
{

View File

@ -100,14 +100,14 @@ namespace nana
tmp.swap(displays);
}
static BOOL __stdcall enum_proc(HMONITOR handle, HDC context, LPRECT r, LPARAM self_ptr)
static BOOL __stdcall enum_proc(HMONITOR handle, HDC /*context*/, LPRECT /*r*/, LPARAM self_ptr)
{
auto disp_cont = reinterpret_cast<std::vector<real_display>*>(self_ptr);
MONITORINFOEX mi;
mi.cbSize = sizeof(MONITORINFOEX);
if (::GetMonitorInfo(handle, &mi))
disp_cont->emplace_back(disp_cont->size(), mi);
return TRUE;
}
#else

View File

@ -142,7 +142,7 @@ namespace nana
}; //end class timer_core
#if defined(NANA_WINDOWS)
void __stdcall timer_driver::_m_timer_proc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
void __stdcall timer_driver::_m_timer_proc(HWND /*hwnd*/, UINT /*uMsg*/, UINT_PTR id, DWORD /*dwTime*/)
#else
void timer_driver::_m_timer_proc(std::size_t id)
#endif