diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-09-07 08:01:00 -0300 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2017-11-23 12:51:31 +0000 |
commit | 2aaf5753197c87a0b3730850a1ab851ffb854d9e (patch) | |
tree | d0e29f93bf611b9f531e35fd7d259daff7b756f4 /src/corelib/io/qfilesystemengine_unix.cpp | |
parent | 915a81d7122fbcb6b28a5368c4d0364f60159bd6 (diff) |
Fix the build if st_atimensec is defined
It's a trick used by some C libraries to keep compatibility with BSD
extensions while supporting POSIX.1-2008 API. st_atimensec is defined as
st_atim.tv_nsec, so the code would expand to invalid C++
In substitution of 'template<class T> typename std::enable_if<((&T::st_atim.tv_nsec), true), long long int>::type{anonymous}::GetFileTimes::atime(const T&, int) [with T = stat]':
error: invalid use of non-static data member 'stat::st_atim'
Change-Id: I38341f8155354cc4a776fffd14e20f4fc0f6d5bb
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 4051dc43a1..b1f2fca32b 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -202,6 +202,8 @@ static inline typename QtPrivate::QEnableIf<(&T::st_atimespec, &T::st_mtimespec, modification->tv_usec = p->st_mtimespec.tv_nsec / 1000; } +# ifndef st_atimensec +// if "st_atimensec" is defined, this would expand to invalid C++ template <typename T> static inline typename QtPrivate::QEnableIf<(&T::st_atimensec, &T::st_mtimensec, true)>::Type get(const T *p, struct timeval *access, struct timeval *modification) { @@ -211,6 +213,7 @@ static inline typename QtPrivate::QEnableIf<(&T::st_atimensec, &T::st_mtimensec, modification->tv_sec = p->st_mtime; modification->tv_usec = p->st_mtimensec / 1000; } +# endif #endif qint64 timespecToMSecs(const timespec &spec) @@ -268,6 +271,7 @@ mtime(const T &statBuffer, int) { return timespecToMSecs(statBuffer.st_mtimespec); } #endif +#ifndef st_mtimensec // Xtimensec template <typename T> Q_DECL_UNUSED static typename std::enable_if<(&T::st_atimensec, true), qint64>::type @@ -288,8 +292,9 @@ template <typename T> Q_DECL_UNUSED static typename std::enable_if<(&T::st_mtimensec, true), qint64>::type mtime(const T &statBuffer, int) { return statBuffer.st_mtime * Q_INT64_C(1000) + statBuffer.st_mtimensec / 1000000; } -} -} +#endif +} // namespace GetFileTimes +} // unnamed namespace #ifdef STATX_BASIC_STATS static int qt_real_statx(int fd, const char *pathname, int flags, struct statx *statxBuffer) |