• C



i am using hrtime_t and it cant seem to compile..if i am interested in finding time between code, do i use gethrtime or is there anything else?i am using linux.
Who is Participating?
gethrtime is a Solaris function, which is generally not available on Linux (and if it is, it's probably not exactly the same).

It could be that your Linux platform has it in another include file. You could to a grep in the include files to find out if one of them contains it, but I wouldn't count on it.

Consider using clock_gettime instead for Linux :

>> and it cant seem to compile.

Maybe you could show some code, and explain how it doesn't compile, by posting the exact error messages, etc.
zizi21Author Commented:
these are the errors...
test.c:159: error: `hrtime_t' undeclared (first use this function)
test.c:159: error: (Each undeclared identifier is reported only once for each function it appears in.)
test.c:159: error: expected `;' before "start"
test.c:162: error: `start' undeclared (first use this function)
test.c:162: error: `gethrtime' undeclared (first use this function)
test.c:165: error: `end' undeclared (first use this function)
make: *** [test.o] Error 1

#include <sys/time.h>
hrtime_t start, end;
int i, iters = 100;

start = gethrtime();
for (i = 0; i < iters; i++)
end = gethrtime();

i am running on linux and i am getting an errors. but when i run on solaris...no error and the code compile..
zizi21Author Commented:
thanks a million..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.