为什么clang ++ / g ++在Mac OSX中没有为chrono :: high_resolution_clock :: now()提供正确的微秒输出?

时间:2017-08-25 13:31:35

标签: c++ macos clang c++14 chrono

#include<iostream>
#include<chrono>
using namespace std;

int main ()
{
  cout << "now = " << chrono::duration_cast<chrono::microseconds>
  (chrono::high_resolution_clock::now().time_since_epoch()).count() << "\n";
}

上面用clang ++(或g ++)编译的简单程序在我的Macbook Air Sierra中返回了错误的输出:

now = 28536840800

相同的代码在Ubuntu [也是Windows,Android ...]中正常运行,输出正确:

now = 1503667687247859

检查标准库头文件后,microseconds::rep大小为8个字节(long long)。
Mac机有什么问题?

0 个答案:

没有答案