Solved

urgent:gethrtime

Posted on 2009-04-14
4
849 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

Independent Software Vendors: 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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

763 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