Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-23-2006, 01:02 PM
|
#1
|
|
Member
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547
Rep:
|
compiling problem?
i have this example.
#include <unistd.h>
int main()
{
usleep(1000);
return 0;
}
that compiles fine with gcc -Wall test.c -o test
but with:
gcc -c -Wall -O2 -g -O2 -ansi -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/X11R6/include -I/usr/X11R6/include -I/usr/include/gtk-2.0 -I/usr/include `pkg-config gtk+-2.0 --cflags --libs` test.c
I get test.c:4: warning: implicit declaration of function ‘usleep’
and no warning eliminating -ansi
so do I have any danger ignoring the warning or shall I skipp -ansi?
|
|
|
|
08-23-2006, 01:13 PM
|
#2
|
|
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065
Rep:
|
> and no warning eliminating -ansi
is usleep standard?
|
|
|
|
08-23-2006, 02:29 PM
|
#3
|
|
Member
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547
Original Poster
Rep:
|
I guess not.
from man 3 usleep
SYNOPSIS
/* BSD version */
#include <unistd.h>
void usleep(unsigned long usec);
/* SUSv2 version */
#define _XOPEN_SOURCE 500
#include <unistd.h>
int usleep(useconds_t usec);
|
|
|
|
08-23-2006, 02:33 PM
|
#4
|
|
Member
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547
Original Poster
Rep:
|
maybe I should use nanosleep instead from time.h
|
|
|
|
08-23-2006, 02:57 PM
|
#5
|
|
Member
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547
Original Poster
Rep:
|
sorry I saw now in the man page: This function is obsolete. Use nanosleep(2) or setitimer(2) instead.
so I go for nanosleep.
|
|
|
|
08-24-2006, 01:58 AM
|
#6
|
|
Member
Registered: Jun 2005
Posts: 199
Rep:
|
Just a caution - the use of 'test' as a name for the compiled program conflicts with bash.
Also you can use -Wall in g++
|
|
|
|
08-24-2006, 07:47 AM
|
#7
|
|
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065
Rep:
|
Quote:
|
Originally Posted by whk
Just a caution - the use of 'test' as a name for the compiled program conflicts with bash.
Also you can use -Wall in g++
|
as long as you specify the absolute path to your test executable (./test) you should be fine.
i would also agree that -Wall is a good habit to get into
|
|
|
|
08-26-2006, 07:45 AM
|
#8
|
|
Member
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547
Original Poster
Rep:
|
ok I shall use another name then test in the future even if I have a absolute path. One day I will not an get in to trouble.
Thanks.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:22 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|