【问题标题】:objective-c gettimeofday must be imported?必须导入objective-c gettimeofday?
【发布时间】:2016-03-29 13:46:53
【问题描述】:

我正在尝试在 Objective-C 中使用 gettimeofday。但是,我遇到了这两个问题:

  1. “函数 'gettimeofday' 的隐式声明在 C99 中无效”

  2. “'gettimeofday' 的声明必须先从模块 'Darwin.POSIX.sys.time' 导入”

我已经执行了这些导入:

#import <UIKit/UIKit.h>
#include <time.h>

但问题仍然存在?

提前致谢。 /JBJ

【问题讨论】:

    标签: ios objective-c xcode


    【解决方案1】:

    导入&lt;sys/time.h&gt; 而不是#include &lt;time.h&gt;

    Ctime.h中声明了time()、clock()等函数;在POSIX(操作系统规范)中,它具有所有C 结构和宏,并在sys/time.h 中使用时间间隔函数进行了扩展。

    【讨论】:

    • @KDeogharkar,也解决了我的问题。你会如何解释这个原因呢?
    猜你喜欢
    • 1970-01-01
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 2010-10-09
    • 2011-08-29
    相关资源
    最近更新 更多