Solved

urgent:gethrtime

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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 and use switch statements in the C programming language.

864 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now