Table of Contents


nemo_main - preferred main entry point for NEMO C and C++ programs


#include <stdinc.h>
#include <getparam.h>
string defv[] = {
    "key=val\n       helpstring",
    "VERSION=x.y\n   mm-ddd-yy  AUTHOR",
string usage="Usage message ... ";
string cvsid="$Id: nemomain.3,v 1.3 2004/12/09 05:39:27 pteuben Exp $"; 

void nemo_main(void)


nemo_main can be called to free the programmer of calling the standard startup and shutdown code which deals with the user interface. This also allows the future NEMO libraries to have a different setup for startup and/or shutdown of a single task.

Instead of starting a program with main(argc,argv) a NEMO program should be started with nemo_main(), but see LIMITATIONS below.

The code for nemo_main looks something like:

   #include <stdinc.h>
   #include <getparam.h>
   extern string defv[];           /* defv MUST be defined in user program
! */
   void main(argc,argv)
   int argc;                               /* number of arguments + 1 */
   char *argv[];                           /* pointer to arguments */
      if(argv[argc] != NULL)
         warning("Your C compiler seems to have an old-style (short) argv[]");
      initparam(argv,defv);               /* start  */
      nemo_main();                        /* call program */
      finiparam();                        /* end */
      exit(0);                            /* return normal status to shell


The pointer to the array of key=value default keywords (see getparam(3NEMO) ) MUST be called by name defv as shown in the SYNOPSIS section above, since nemo_main defines this as extern string defv[]. Stubbed code exist within the NEMO library in defv.c and usage.c, to ensure that programs will still link. They will however have no controlled access to the commandline arguments.

See Also



~/src/kernel/misc    nemomain.c    c and c++ versions
~/src/kernel/io      defv.c usage.c        stubs for missing extern


Peter Teuben

Update History

29-jun-89    created      PJT
28-nov-94    doc             PJT
17-mar-04    void        PJT

Table of Contents