[Coco] Can I pass command line parameters to a cmoc program from os9 ?

Jeff Teunissen deek at d2dc.net
Sun Jul 23 06:34:10 EDT 2023


You need to NOT replace <stdio.h> with <stdarg.h>. All <stdarg.h> does
is declare va_list / va_arg / va_end. It's useful for variadic
functions (the sort that have an ellipsis, "...", in their argument
list, but it's got nothing to do with what you're trying to do.

<stdio.h> is the header that declares all of the I/O functions,
variables, and defines -- fread, fwrite, printf, etc.

On Sat, Jul 22, 2023 at 6:18 PM coco--- via Coco <coco at maltedmedia.com> wrote:
>
> Sean
> CC:all
>
> Thanks Sean
> This is good does pretty much what I want.
>
> Some notes for CMOC though
> I needed to replace #include <stdio.h>
> with
> #include <stdarg.h>
> #include <coco.h>
>
> Otherwise it worked just like expected except that
> argv[0] came out as "" not "cc" or "main".
>
> Charlie
>
> On 2023-07-22 16:27, Sean Conner via Coco wrote:
> > It was thus said that the Great coco--- via Coco once stated:
> >> All
> >>
> >> Wanted to know how to pass a parameter from the OS9
> >> command line into a CMOC generated program. Found no
> >> usefull examples in the CMOC manual ...
> >
> >   Try the following program:
> >
> > ======================
> >
> > #include <stdio.h>
> >
> > int main(int argc,char *argv[])
> > {
> >   int i;
> >
> >   for (i = 0 ; i < argc ; i++)
> >   {
> >     printf("command line argument %d: '%s'\n",i,argv[i]);
> >   }
> >   return 0;
> > }
> >
> > ======================
> >
> >   In C, the function main() gets the command line broken up by
> > whitespace
> > and each "argument" in the argv[] array.  By convention, argv[0] is the
> > program name itself.
> >
> >   The C standard doesn't define the getopt.h header---that is specified
> > by
> > POSIX (read: water downed Unix).  If getopt.h doesn't exist for your
> > system,
> > then you'll have to write code to look through the argv[] array passed
> > to
> > main().
> >
> >   -spc
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco


More information about the Coco mailing list