Hi,
I keep getting the warning of:
whenever i use getline() functionCode:Implicit declaration of funciton getline()
What does this warning mean actually ?
Is this a serious warning, or just ignorable.
Cheer!!
Hi,
I keep getting the warning of:
whenever i use getline() functionCode:Implicit declaration of funciton getline()
What does this warning mean actually ?
Is this a serious warning, or just ignorable.
Cheer!!
getline() is c++ not C. There is no standard C getline() function.
getline() is also a GNU provided extension available under #include <stdio.h>. It will not appear if you use the -ansi flag, because the -ansi flag excludes all GNU extensions. It's not part of standard C, as Ancient Dragon said.
replace getline() with fgets() and your program will (maybe) work.
What's happening is that you have tried to use a function called getline() that hasn't been declared anywhere (eg in a header file) and the compiler takes your attempt to call it as an implicit declaration.
As other have sort of said, your real problem is probably that you're calling a function that doesn't exist and you need to work out what function you really intend to call. If the function is one you actually know you're trying to call, find the corresponding header file and #include it.
Code:$ grep -n getline /usr/include/*.h
If you're trying to use the C++ getline, then you need <iosteam> etc.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Sorry if I am a topic digging here, but I came across this thread while searching for the answer for exactly this problem and I noticed noone here gave the right answer.
The answer turned out pretty simple:
getline() IS a valid C function which is defined in stdio.h. As some people rightfully suggested it is not a function that is defined in the ANSI standard, but it is a GNU extension. In order to correctly include these extensions you have to add a define:
Ofcourse this only works if you are actually using glibc (e.g. on Linux or cygwin).Code:#define _GNU_SOURCE #include <stdio.h> /* functions like getline() and getdelim() should be defined now */
Hope this clarifies the issue.
-- LT
Depends on your perspective. I consider your post to be incorrect and misleading, as you make some statements early on which are compiler/library specific but you state them as generalities. Yes you correct them later, sort of, but the information you give is not generally true.Originally Posted by Lord Thunder
No. The functions that are declared in <stdio.h> are specified in the ISO C standard. They are not required to be defined in stdio.h.Originally Posted by Lord Thunder
Reliance on stdio.h declaring any function that is not specified in the C standard is invalid, unless you are prepared to constrain yourself to only one compiler and it's library (and possibly to a particular version of that compiler and library).
Exactly my point. There are a few commonly used compilers that are produced by vendors not associated with GNU. Most of those compilers do not support GNU extensions and are not bunded with glibc.Originally Posted by Lord Thunder
Sort of. glibc, in practical terms, often relies on using a correct version of gcc (the GNU compiler collection). Several versions of glibc only work with particular versions of gcc. This is the reason that the gnu compiler and glibc are often bundled together, particularly with recent versions. Both the gnu compiler and library are supported on more systems than linux; cygwin is just one of several windows ports.Originally Posted by Lord Thunder
Originally Posted by Lord Thunder
Why is it exactly that you are dredging up a 7 month old thread? Was the urge so strong to blabber that you could not resist? Give me a break.
Forum Guidelines. Read before posting:
Any questions?5. Don't bump threads. (Bumping: posting messages on threads to move them up the list or to post on a thread that has been inactive for two weeks or longer).