相关疑难解决方法(0)

GCC中的std :: put_time实施状态?

我试图使用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_timechrono或相似.任何人都可以指向我提供有关此库的实现状态的信息的资源吗?

c++ gcc std c++11 c++-chrono

63
推荐指数
2
解决办法
2万
查看次数

如何使用gettimeofday()或与Visual Studio C++ 2008等效的东西?

有人可以帮我在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)

c visual-studio-2008 visual-studio visual-c++ gettimeofday

10
推荐指数
3
解决办法
6万
查看次数