Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

C: implicit declaration of function 'foo'

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
allucid
Veteran
Veteran
Posts: 1314
Joined: Sat Nov 02, 2002 6:27 pm
Location: atlanta

C: implicit declaration of function 'foo'

  • Quote

Post by allucid » Sun Jun 26, 2005 10:34 pm

I keep getting these warnings and I would like to find out why.

Here's a couple examples of the ones I am getting:

Code: Select all

io.c:98: warning: implicit declaration of function `readdir_r'
markovlet.c:46: warning: implicit declaration of function `random'
random.c:30: warning: implicit declaration of function `srandom'
server.c:169: warning: implicit declaration of function `fdopen'
server.c:194: warning: implicit declaration of function `fileno'
For all the listed functions I checked the manpages and made sure I included all the necessary header files. I don't know where else to look.
Top
widan
Veteran
Veteran
User avatar
Posts: 1512
Joined: Tue Jun 07, 2005 4:26 pm
Location: Paris, France

  • Quote

Post by widan » Sun Jun 26, 2005 10:48 pm

You're probably compiling with the "-ansi" flag, and those functions aren't defined in ANSI C. They're POSIX functions. Look in the man pages, at the very bottom there is a section "CONFORMING TO":

Code: Select all

CONFORMING TO
       The fopen and freopen functions conform  to  ANSI  X3.159-1989  (``ANSI
       C'').    The   fdopen   function   conforms   to   IEEE  Std1003.1-1988
       (``POSIX.1'').
When you compile in "-ansi" mode, gcc does not define some constants (__USE_GNU, __USE_POSIX, __USE_BSD, maybe others), that cause some function prototypes to be skipped in system headers (for example in stdio.h):

Code: Select all

#ifdef	__USE_POSIX
/* Create a new stream that refers to an existing system file descriptor.  */
extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
#endif
Top
allucid
Veteran
Veteran
Posts: 1314
Joined: Sat Nov 02, 2002 6:27 pm
Location: atlanta

  • Quote

Post by allucid » Sun Jun 26, 2005 11:01 pm

I am not using -ansi but I am using -std=c99. Changing that to -std=gnu99 seemed fixed those warnings (it also caused another error but I'm working on fixing that). The other person who is working on the project with me is using gcc with the same flags but is not getting all the warnings that I am which added to my confusion. Thanks for the help!
Top
TrueDFX
Retired Dev
Retired Dev
Posts: 1348
Joined: Wed Jun 02, 2004 5:33 pm

  • Quote

Post by TrueDFX » Sun Jun 26, 2005 11:20 pm

You can use -std=c99, as long as you also add -D_POSIX_C_SOURCE=200112L (or better, #define it before #including any of the headers). POSIX requires it anyway.
Top
Post Reply

4 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic