mirror of
https://github.com/HowardHinnant/date.git
synced 2025-01-14 09:47:57 +08:00
Prevent warnings when using -Wundef flag
This commit is contained in:
parent
7331f36318
commit
52e2a0b2cf
8
date.h
8
date.h
@ -957,7 +957,7 @@ trunc(const std::chrono::duration<Rep, Period>& d)
|
||||
}
|
||||
|
||||
// VS Update 2 provides floor, ceil, round, abs in chrono.
|
||||
#if _MSC_FULL_VER < 190023918
|
||||
#if !defined(_MSC_FULL_VER) || _MSC_FULL_VER < 190023918
|
||||
|
||||
// round down
|
||||
template <class To, class Rep, class Period>
|
||||
@ -1054,14 +1054,14 @@ ceil(const std::chrono::time_point<Clock, FromDuration>& tp)
|
||||
return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
|
||||
}
|
||||
|
||||
#else // _MSC_FULL_VER < 190023918
|
||||
#else // !defined(_MSC_FULL_VER) || _MSC_FULL_VER < 190023918
|
||||
|
||||
using std::chrono::floor;
|
||||
using std::chrono::ceil;
|
||||
using std::chrono::round;
|
||||
using std::chrono::abs;
|
||||
|
||||
#endif // _MSC_FULL_VER < 190023918
|
||||
#endif // !defined(_MSC_FULL_VER) || _MSC_FULL_VER < 190023918
|
||||
|
||||
// trunc towards zero
|
||||
template <class To, class Clock, class FromDuration>
|
||||
@ -3829,7 +3829,7 @@ class time_of_day
|
||||
{
|
||||
using base = detail::time_of_day_storage<Duration>;
|
||||
public:
|
||||
#if !(_MSC_VER && !defined(__clang__))
|
||||
#if !(defined(_MSC_VER) && !defined(__clang__))
|
||||
// C++11
|
||||
using base::base;
|
||||
#else
|
||||
|
40
tz.cpp
40
tz.cpp
@ -25,7 +25,7 @@
|
||||
// been invented (that woud involve another several millennia of evolution).
|
||||
// We did not mean to shout.
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
// Windows.h will be included directly and indirectly (e.g. by curl).
|
||||
// We need to define these macros to prevent Windows.h bringing in
|
||||
// more than we need and do it eearly so Windows.h doesn't get included
|
||||
@ -49,7 +49,7 @@
|
||||
// https://msdn.microsoft.com/en-nz/library/windows/desktop/aa383745(v=vs.85).aspx
|
||||
// that "If you define NTDDI_VERSION, you must also define _WIN32_WINNT."
|
||||
// So we declare we require Vista or greater.
|
||||
#if __MINGW32__
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#ifndef NTDDI_VERSION
|
||||
#define NTDDI_VERSION 0x06000000
|
||||
@ -87,7 +87,7 @@
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#endif // _WIN32
|
||||
@ -96,7 +96,7 @@
|
||||
// the current time zone. On Win32 Windows.h provides a means to do it.
|
||||
// gcc/mingw supports unistd.h on Win32 but MSVC does not.
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
# include <io.h> // _unlink etc.
|
||||
# include <ShlObj.h> // CoTaskFree, ShGetKnownFolderPath etc.
|
||||
# if HAS_REMOTE_API
|
||||
@ -122,7 +122,7 @@
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
static CONSTDATA char folder_delimiter = '\\';
|
||||
|
||||
namespace
|
||||
@ -197,7 +197,7 @@ namespace date
|
||||
|
||||
static std::string get_install()
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
std::string install = get_download_folder();
|
||||
install += folder_delimiter;
|
||||
install += "tzdata";
|
||||
@ -243,7 +243,7 @@ struct undocumented {explicit undocumented() = default;};
|
||||
static_assert(min_year <= max_year, "Configuration error");
|
||||
#endif
|
||||
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
|
||||
namespace // Put types in an anonymous name space.
|
||||
{
|
||||
@ -2167,7 +2167,7 @@ static
|
||||
bool
|
||||
file_exists(const std::string& filename)
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
return ::_access(filename.c_str(), 0) == 0;
|
||||
#else
|
||||
return ::access(filename.c_str(), F_OK) == 0;
|
||||
@ -2283,7 +2283,7 @@ remote_download(const std::string& version)
|
||||
".tar.gz";
|
||||
bool result = download_to_file(url, get_download_gz_file(version),
|
||||
download_file_options::binary);
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
if (result)
|
||||
{
|
||||
auto mapping_file = get_download_mapping_file(version);
|
||||
@ -2306,7 +2306,7 @@ static
|
||||
bool
|
||||
remove_folder_and_subfolders(const std::string& folder)
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
# if USE_SHELL_API
|
||||
// Delete the folder contents by deleting the folder.
|
||||
std::string cmd = "rd /s /q \"";
|
||||
@ -2385,7 +2385,7 @@ static
|
||||
bool
|
||||
make_directory(const std::string& folder)
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
# if USE_SHELL_API
|
||||
// Re-create the folder.
|
||||
std::string cmd = "mkdir \"";
|
||||
@ -2408,7 +2408,7 @@ static
|
||||
bool
|
||||
delete_file(const std::string& file)
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
# if USE_SHELL_API
|
||||
std::string cmd = "del \"";
|
||||
cmd += file;
|
||||
@ -2426,13 +2426,13 @@ delete_file(const std::string& file)
|
||||
#endif // !WIN32
|
||||
}
|
||||
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
|
||||
static
|
||||
bool
|
||||
move_file(const std::string& from, const std::string& to)
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
# if USE_SHELL_API
|
||||
std::string cmd = "move \"";
|
||||
cmd += from;
|
||||
@ -2454,7 +2454,7 @@ move_file(const std::string& from, const std::string& to)
|
||||
|
||||
#endif // TIMEZONE_MAPPING
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
// Note folder can and usually does contain spaces.
|
||||
static
|
||||
@ -2684,7 +2684,7 @@ remote_install(const std::string& version)
|
||||
{
|
||||
if (extract_gz_file(version, gz_file, install))
|
||||
success = true;
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
auto mapping_file_source = get_download_mapping_file(version);
|
||||
auto mapping_file_dest = install;
|
||||
mapping_file_dest += folder_delimiter;
|
||||
@ -2830,7 +2830,7 @@ init_tzdb()
|
||||
std::sort(db.leaps.begin(), db.leaps.end());
|
||||
db.leaps.shrink_to_fit();
|
||||
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
std::string mapping_file = path + "windowsZones.xml";
|
||||
db.mappings = load_timezone_mappings_from_xml_file(mapping_file);
|
||||
sort_zone_mappings(db.mappings);
|
||||
@ -2983,12 +2983,12 @@ operator<<(std::ostream& os, const local_info& r)
|
||||
return os;
|
||||
}
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
|
||||
const time_zone*
|
||||
current_zone()
|
||||
{
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
TIME_ZONE_INFORMATION tzi{};
|
||||
DWORD tz_result = ::GetTimeZoneInformation(&tzi);
|
||||
if (tz_result == TIME_ZONE_ID_INVALID)
|
||||
@ -3104,7 +3104,7 @@ current_zone()
|
||||
|
||||
#endif // !WIN32
|
||||
|
||||
#if TZ_TEST && TIMEZONE_MAPPING
|
||||
#if defined(TZ_TEST) && defined(TIMEZONE_MAPPING)
|
||||
|
||||
const time_zone*
|
||||
locate_native_zone(const std::string& native_tz_name)
|
||||
|
20
tz.h
20
tz.h
@ -40,12 +40,12 @@
|
||||
// required. On Windows, the names are never "Standard" so mapping is always required.
|
||||
// Technically any OS may use the mapping process but currently only Windows does use it.
|
||||
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
# ifndef TIMEZONE_MAPPING
|
||||
# define TIMEZONE_MAPPING 1
|
||||
# endif
|
||||
#else
|
||||
# if TIMEZONE_MAPPING
|
||||
# ifdef TIMEZONE_MAPPING
|
||||
# error "Timezone mapping is not required or not implemented for this platform."
|
||||
# endif
|
||||
#endif
|
||||
@ -55,7 +55,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef HAS_REMOTE_API
|
||||
# if _WIN32
|
||||
# ifdef _WIN32
|
||||
# define HAS_REMOTE_API 0
|
||||
# else
|
||||
# define HAS_REMOTE_API 1
|
||||
@ -69,6 +69,10 @@
|
||||
static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true,
|
||||
"AUTO_DOWNLOAD can not be turned on without HAS_REMOTE_API");
|
||||
|
||||
#ifndef USE_SHELL_API
|
||||
# define USE_SHELL_API 0
|
||||
#endif
|
||||
|
||||
#include "date.h"
|
||||
|
||||
#include <algorithm>
|
||||
@ -625,7 +629,7 @@ operator>=(const sys_time<Duration>& x, const leap& y)
|
||||
return !(x < y);
|
||||
}
|
||||
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@ -677,7 +681,7 @@ struct TZ_DB
|
||||
std::vector<link> links;
|
||||
std::vector<leap> leaps;
|
||||
std::vector<Rule> rules;
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
// TODO! These need some protection.
|
||||
std::vector<detail::timezone_mapping> mappings;
|
||||
std::vector<detail::timezone_info> native_zones;
|
||||
@ -695,7 +699,7 @@ struct TZ_DB
|
||||
links(std::move(src.links)),
|
||||
leaps(std::move(src.leaps)),
|
||||
rules(std::move(src.rules))
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
,
|
||||
mappings(std::move(src.mappings)),
|
||||
native_zones(std::move(src.native_zones))
|
||||
@ -709,7 +713,7 @@ struct TZ_DB
|
||||
links = std::move(src.links);
|
||||
leaps = std::move(src.leaps);
|
||||
rules = std::move(src.rules);
|
||||
#if TIMEZONE_MAPPING
|
||||
#ifdef TIMEZONE_MAPPING
|
||||
mappings = std::move(src.mappings);
|
||||
native_zones = std::move(src.native_zones);
|
||||
#endif
|
||||
@ -1677,7 +1681,7 @@ parse(std::basic_istream<CharT, Traits>& is,
|
||||
f.get(is, 0, is, err, &tm, b, e);
|
||||
if ((err & ios_base::failbit) == 0)
|
||||
{
|
||||
#if _WIN32
|
||||
#ifdef _WIN32
|
||||
auto tt = _mkgmtime(&tm);
|
||||
#else
|
||||
auto tt = timegm(&tm);
|
||||
|
Loading…
x
Reference in New Issue
Block a user