Solved

urgent:gethrtime

Posted on 2009-04-14
4
863 Views
Last Modified: 2012-05-06
hi,

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.
0
Comment
Question by:zizi21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 24145454
>> 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.
0
 

Author Comment

by:zizi21
ID: 24146290
ok..
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++)
       printf("hello");
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..
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 24146498
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 :

        http://linux.die.net/man/3/clock_gettime
0
 

Author Comment

by:zizi21
ID: 24146626
thanks a million..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question