Using timersub on Ubuntu Linux

A

Aaron

I'm trying to use timersub from sys/time.h. It looks like my source
code is correct but when I compile I get this warning:

gcc --std=c99 -c <file>
<file>.c:<line #>: warning: implicit declaration of function
'timersub'

From what I understand that means that timersub was not #included in
any header files. My abridged code is:
#include <time.h>
#include <sys/time.h>

int main () {
struct timeval *time_start, *time_end, *time_diff;

gettimeofday(time_start, NULL);
// Some stuff runs
gettimeofday(time_end, NULL);
timersub(time_start, time_end, time_diff);
}

Cheers!
Aaron



As a side question, how do use scanf with the contents of the time
 
F

Flash Gordon

Aaron wrote, On 05/10/08 19:55:
I'm trying to use timersub from sys/time.h. It looks like my source

<snip>

You need to wait a *lot* longer than an hour and a half before assuming
that there are no replies. They may not have reached Google yet, but
there are replies.

In any case, timersub is not part of standard C, rather it is an
extensions commonly provided on systems derived or borrowing from BSD. I
suggest asking in a Linux group or maybe comp.unix.programmer if you
need more help.
As a side question, how do use scanf with the contents of the time

If you have the time as a string then you can parse it with sscanf just
like any other string.
 
A

Antoninus Twink

I'm trying to use timersub from sys/time.h.

Your question has received two correct replies, from Jacob Navia and
Nate Eldredge. If you don't follow something they said, then ask about
it specifically.

<quote from timersub manpage>
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
All functions shown above: _BSD_SOURCE
</quote>

As it says, man 7 feature_test_macros for more information.
 
D

Default User

Flash Gordon wrote:

You need to wait a lot longer than an hour and a half before assuming
that there are no replies. They may not have reached Google yet, but
there are replies.

GG went through another of its periodic hiccups, so users weren't
seeing their own posts show up.




Brian
 
F

Flash Gordon

Default User wrote, On 05/10/08 21:57:
GG went through another of its periodic hiccups, so users weren't
seeing their own posts show up.

<shrug>

In that case GG users need to wait longer before assuming their posts
won't show up.
 
D

Default User

Flash said:
Default User wrote, On 05/10/08 21:57:

<shrug>

In that case GG users need to wait longer before assuming their posts
won't show up.

When possible, they should get a real news service. There are number of
free or low-cost solutions that are much more useful than GG.




Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top