Solved

urgent:gethrtime

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

759 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

22 Experts available now in Live!

Get 1:1 Help Now