function reference from standard library

C. M. Heard/VVNET, Inc. heard@vvnet.com
Mon Oct 12 09:10:00 GMT 1998


On Mon, 12 Oct 1998, Dony wrote:

> Hii all,
> 
> Another confusion in GCC :
> In my code I use 'strlen()' from standard library 'string.h'
> I have already included the header --->>> #include <string.h>
> Code is successfuly being compiled, but during linking, an error happens
> --->>> main.c(.text+0x666):main.c: undefined reference to strlen

Apparently the linker is not finding your libraries.

>
> Beside that I get a warning (I don't know would whether it will effect
> the functionality of my program or not), as I define main(){ ....}.
> The message is like this :
> main.c:51: warning: return-type defaults to 'int'  --->>> point to line
> begin of fucntion main()
> main.c:153: warning: control reaches end of non-void function  --->>>
> point to end of function main()

The declaration "main ()" is equivalent to "int main ()", as it has been
since K&R C days.  I think that the latest ISO C standard has decreed that
the omission of "int" in a declaration  is an anachronism, and for this
reason it draws a warning from gcc.  You should change your declaration
to "int main (void)" [not "void main (void)" ... I don't think that's
considered legal anymore, if it ever was] and end the function with
"return 0" to stop these complaints.

> 
> Can anybody explain on that??
> Thank's
> 
> -- 
> Dony
> Email : dony@willowglen.com.sg

Mike
--
C. M. Heard/VVNET, Inc.
heard@vvnet.com

________________________________________________
To get help for the crossgcc list, send mail to
crossgcc-request@cygnus.com with the text 'help'
(without the quotes) in the body of the message.



More information about the crossgcc mailing list