function reference from standard library

Art Berggreen art@acc.com
Tue Oct 13 08:15:00 GMT 1998


>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.

Functions returning void are definitely legal.  This specifies that the
function does not return a value.  Any attempt to return with a value
from inside the function will generate a warning.  Any attempt to use
a return value from such a function will also generate a warning.

If you don't want to use the return value of a function, it's a good
practice to cast the return value of the function call to void.  Otherwise
the compiler can complain that you are discarding the return value.

You can also use volatile on functions (I think this is a GNU extension).
This specifies that the function will never return.

Art

________________________________________________
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