相关疑难解决方法(0)

Mac OS X中的clock_gettime替代方案

在通过MacPorts安装必要的库后编译我在Mac OS X上编写的程序时,我收到此错误:

In function 'nanotime':
error: 'CLOCK_REALTIME' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
Run Code Online (Sandbox Code Playgroud)

它似乎clock_gettime没有在Mac OS X中实现.是否有另一种方法可以在纳秒内获得纪元时间?不幸的是在几微秒内.gettimeofday

c macos time clock

65
推荐指数
7
解决办法
9万
查看次数

iPhone:如何根据更改设备的日期来修复作弊行为?我可以从那里获得时间的服务器吗?

我有一个iPhone游戏,该游戏会随着时间的流逝分配游戏中的货币,有人发现您可以更改设备上的日期以尽早获得奖励。

我发现蓝精灵村(Smurf Village)也有类似的问题,他们以某种方式发现了篡改行为。有人知道他们是怎么做的吗?我唯一能想到的就是从外部服务器获取时间,这将要求设备处于联机状态,但总比没有好。...有人知道我在哪里可以找到只告诉您时间的服务器吗?

iphone time datetime ipod nsdate

6
推荐指数
1
解决办法
9370
查看次数

Linux和OS X上的C语言中的ns精度单调时钟

clock_gettime(CLOCK_MONOTONIC, ...) 可用于Linux而不是OS X.Mach计时器可在OS X中使用,但在Linux中不可用.

如何在C中获得ns精度单调时钟,这在Linux和OS X上都有效?

c linux macos time

4
推荐指数
1
解决办法
2665
查看次数

boost chrono endTime - startTime在boost 1.51中返回负数

当我减去endTime - startTime时,我的macbook pro上的boost chrono library vs1.51返回负数.如果打印时间点,则会看到结束时间早于startTime.怎么会发生这种情况?

typedef boost::chrono::steady_clock clock_t;
clock_t clock;

// Start time measurement
boost::chrono::time_point<clock_t>  startTime = clock.now();
short test_times = 7;

// Spend some time...
for ( int i=0; i<test_times; ++i )
{
   xnodeptr spResultDoc=parser.parse(inputSrc);

  xstring sXmlResult = spResultDoc->str();
  const char16_t* szDbg = sXmlResult.c_str();

  BOOST_CHECK(spResultDoc->getNodeType()==xnode::DOCUMENT_NODE && sXmlResult == sXml);
}

// Stop time measurement
boost::chrono::time_point<clock_t> endTime = clock.now();
clock_t::duration elapsed( endTime - startTime);

std::cout << std::endl;
std::cout << "Now time: " << clock.now() << std::endl;
std::cout << …
Run Code Online (Sandbox Code Playgroud)

c++ boost c++-chrono

3
推荐指数
1
解决办法
1425
查看次数

标签 统计

time ×3

c ×2

macos ×2

boost ×1

c++ ×1

c++-chrono ×1

clock ×1

datetime ×1

iphone ×1

ipod ×1

linux ×1

nsdate ×1