我试图使用GCC(测试版本4.5.1,4.6.3,4.8.4)编译此示例程序:
#include <iostream>
#include <iomanip>
#include <ctime>
#include <chrono>
using std::chrono::system_clock;
int main()
{
system_clock::time_point now = system_clock::now();
std::time_t now_c = system_clock::to_time_t(
now - std::chrono::hours(24));
std::cout << "One day ago, the time was "
<< std::put_time(std::localtime(&now_c), "%F %T") << '\n';
}
Run Code Online (Sandbox Code Playgroud)
prog.cpp: In function 'int main()':
prog.cpp:14:18: error: 'put_time' is not a member of 'std'
Run Code Online (Sandbox Code Playgroud)
我想,可能还没有实现.所以我试着检查这个功能的实现状态.我只找到了这个页面:
但我找不到任何笔记put_time或chrono或相似.任何人都可以指向我提供有关此库的实现状态的信息的资源吗?
有人可以帮我在Windows XP上使用Visual Studio C++ 2008的gettimeofday()函数吗?这是我在网上找到的代码:
#include < time.h >
#include <windows.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to …Run Code Online (Sandbox Code Playgroud)