Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objective-c gettimeofday must be imported?

I am trying to use gettimeofday in Objective-C. However, i get these two issues:

  1. "Implicit declaration of function 'gettimeofday' is invalid in C99"

  2. "Declaration of 'gettimeofday' must be imported from module 'Darwin.POSIX.sys.time' before it is required"

I have performed these imports:

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

But the issue still persists?

Thanks in advance. /JBJ

like image 352
J.B.J. Avatar asked Dec 23 '15 07:12

J.B.J.


1 Answers

import <sys/time.h> instead of #include <time.h>

in C time.h declares functions like time(), clock() etc; and In POSIX (OS specification) it has all C structure and macro and it is extended with time interval functions in sys/time.h .

like image 72
KDeogharkar Avatar answered Oct 18 '22 17:10

KDeogharkar