LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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



Reply
 
Search this Thread
Old 08-23-2006, 02:02 PM   #1
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Rep: Reputation: 38
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?
 
Old 08-23-2006, 02:13 PM   #2
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
> and no warning eliminating -ansi

is usleep standard?
 
Old 08-23-2006, 03:29 PM   #3
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Original Poster
Rep: Reputation: 38
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);
 
Old 08-23-2006, 03:33 PM   #4
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Original Poster
Rep: Reputation: 38
maybe I should use nanosleep instead from time.h
 
Old 08-23-2006, 03:57 PM   #5
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Original Poster
Rep: Reputation: 38
sorry I saw now in the man page: This function is obsolete. Use nanosleep(2) or setitimer(2) instead.

so I go for nanosleep.
 
Old 08-24-2006, 02:58 AM   #6
whk
Member
 
Registered: Jun 2005
Posts: 200

Rep: Reputation: 35
Just a caution - the use of 'test' as a name for the compiled program conflicts with bash.

Also you can use -Wall in g++
 
Old 08-24-2006, 08:47 AM   #7
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
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
 
Old 08-26-2006, 08:45 AM   #8
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 547

Original Poster
Rep: Reputation: 38
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Compiling patisawsome Ubuntu 3 03-20-2006 05:44 PM
Problem compiling javakid Programming 8 12-16-2004 01:03 AM
compiling problem ... chaks Programming 2 03-29-2004 10:14 AM
Compiling Problem BACTRATE Mandriva 1 03-12-2004 05:36 AM
problem compiling qt schatoor Linux - Software 3 03-08-2003 03:09 PM


All times are GMT -5. The time now is 11:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration