473,508 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using timersub on Ubuntu Linux

I'm trying to use the timersub macro on Ubuntu Linux. When I compile I
get the error:

<file>.c:<line #>: warning: implicit declaration of function
'timersub'

Where <fileis the file name and <line #is the line number. I take
that to mean I that the timersub macro hasn't been #included. My code
looks about like this:

#include <time.h>
#include <sys/time.h>

struct timeval *time_start, *time_end, *time_diff;

gettimeofday(time_start);
// some stuff runs
gettimeofday(time_end);

timersub(time_start, time_end, time_diff);

What am I doing wrong?

-Aaron
Oct 5 '08 #1
5 13842
aa**********@gmail.com wrote:
I'm trying to use the timersub macro on Ubuntu Linux. When I compile I
get the error:

<file>.c:<line #>: warning: implicit declaration of function
'timersub'

Where <fileis the file name and <line #is the line number. I take
that to mean I that the timersub macro hasn't been #included. My code
looks about like this:

#include <time.h>
#include <sys/time.h>

struct timeval *time_start, *time_end, *time_diff;

gettimeofday(time_start);
// some stuff runs
gettimeofday(time_end);

timersub(time_start, time_end, time_diff);

What am I doing wrong?

-Aaron
timersub is defined in time.h

# define timersub(a, b, result) \
do {
\
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec;
\
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec;
\
if ((result)->tv_usec < 0) {
\
--(result)->tv_sec;
\
(result)->tv_usec += 1000000;
\
}
\
} while (0)
BUT
this macro will be defined ONLY if the preprocessor symbol
__USE_BSD
is defined.

Probably you have to convince gcc to define that symbol.
Read the documentation for that.

In ANY case if the definition isn't seen the link will not work since
timersub is a compiler macro and will be absent from the libraries
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Oct 5 '08 #2
jacob navia <ja***@nospam.comwrites:
aa**********@gmail.com wrote:
>I'm trying to use the timersub macro on Ubuntu Linux. When I compile I
get the error:

<file>.c:<line #>: warning: implicit declaration of function
'timersub'

Where <fileis the file name and <line #is the line number. I take
that to mean I that the timersub macro hasn't been #included. My code
looks about like this:
[snip]
>
timersub is defined in time.h
[snip]
>
BUT
this macro will be defined ONLY if the preprocessor symbol
__USE_BSD
is defined.

Probably you have to convince gcc to define that symbol.
Read the documentation for that.
Specifically, the section of the glibc manual entitled "Feature test
macros". It appears you are supposed to define the macro _BSD_SOURCE
and link with -lbsd_compat.
Oct 5 '08 #3
jacob navia wrote:
aa**********@gmail.com wrote:
>I'm trying to use the timersub macro on Ubuntu Linux. When I
compile I get the error:
.... snip ...
>>
What am I doing wrong?

timersub is defined in time.h
No such thing exists in standard C. Read section 7.23 of the C std.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Oct 6 '08 #4
On 6 Oct 2008 at 1:21, CBFalconer wrote:
jacob navia wrote:
>aa**********@gmail.com wrote:
>>I'm trying to use the timersub macro on Ubuntu Linux.

timersub is defined in time.h

No such thing exists in standard C. Read section 7.23 of the C std.
The OP isn't using "standard C". He's just using C. Read the subject
line, or the words you quoted above - surely even someone in your
advanced stage of senility can't forget words two lines previously?
Here they are again: take note and stop being such an idiot.
>>I'm trying to use the timersub macro on Ubuntu Linux.
Oct 6 '08 #5
In article <48***************@yahoo.com>,
CBFalconer <cb********@maineline.netwrote:
>jacob navia wrote:
>aa**********@gmail.com wrote:
>>I'm trying to use the timersub macro on Ubuntu Linux. When I
compile I get the error:
... snip ...
>>>
What am I doing wrong?

timersub is defined in time.h

No such thing exists in standard C. Read section 7.23 of the C std.
No such thing exists in the Bible either. I suspect both of these
observations are of equal value to the OP.

Oct 6 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2277
by: Google Mike | last post by:
Hey PHP Fans! If you're a Linux fan and haven't installed Screem to see if that doesn't become your favorite PHP editor, I highly recommend it. It's a snap to install on Ubuntu Linux, which has...
8
2470
by: Martin Maney | last post by:
Apologies if this isn't news here - I've been too busy this last week or so for even skimming the traffic here, in part because I've been messing around with Ubuntu's preview release on a spare...
26
2559
by: blah | last post by:
ok, i m going to use Linux for my Python Programs, mainly because i need to see what will these fork() and exec() do. So, can anyone tell me which flavour of linux i should use, some say that...
2
2637
by: SPE - Stani's Python Editor | last post by:
Hi, I'm playing around with the latest (soon to be released) SPE on Ubuntu. This probably will increase the quality of SPE on Ubuntu and Linux/GTK in general. I already made some patches, but I...
4
8995
by: Hitchkas | last post by:
I have a very beginner and fundamental question regarding porting and running C# programs in Linux. As a background I am a total idiot when it comes to Linux but somehow managed to install Ubuntu...
2
2679
by: Dr. Colombes | last post by:
Is there an easy scientific graphics (plotting) package for Python 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? A few years ago I used PyLab (a MatLab-like plotting module for Python) on...
11
2916
by: Ix | last post by:
It seems not remember how to compile with gcc a C program in linux (ubuntu) how i have to compile this programme? It seems gcc doesn't find stdio.h.. why is all antiintuitive? Thank you and...
9
3048
by: Todd Whiteman | last post by:
I've put together a tutorial that shows off how to build a GUI application using XULRunner (same architectural components as Firefox uses) that can be used in conjunction with the Python...
5
921
by: Aaron | last post by:
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...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.