TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Mike Ruskai
from: Ronald Van Iwaarden
date: 1995-04-18 22:51:34
subject: EMX main()

Mike Ruskai said to All:

 MR> Does anyone know why the EMX compiler insists that the main
 MR> function has to  return an integer?  It won't accept void as
 MR> the return type. 

From libref.doc in emx\doc, it states:

int main (void);
int main (int argc, char *argv[]);
int main (int argc, char *argv[], char *envp[]);

    This is the function called by the startup code to run your
    program.  It is not a library function.  ARGC is the number of
    command line arguments, including the program name.  ARGV points
    to an array of pointers to the command line arguments.  ENVP
    points to an array of pointers to the environment strings.  The
    last entry of each array is a NULL pointer.  main() should always
    return a value.  If main() returns, exit() is called using the
    return value of main() as argument.  If main() ends without return
    statement and without calling exit(), the return code of the
    program is undefined.  This should be avoided.  After changing the
    environment with putenv(), you should use the environ global
    variable instead of the ENVP argument of main().

  Return value:

    The return value of main() will be the return code of the process.

you can have void main() and the compiler will give a warning but you can
ignore it (if you really want to).

TTYL,

=--Ron  TeamOS2

Fidonet:  Ronald Van Iwaarden 1:104/338{at}fidonet.org
OS2net:   Ronald Van Iwaarden 81:313/1{at}os2net.ftn
Internet: rvaniwaa{at}carbon.denver.colorado.edu
--- timEd/2-B9
* Origin: The OS/2 Source BBS [303]744-0373 (1:104/338)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809
@PATH: 104/338 730 1 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.