Next: , Previous: Startup codes, Up: Features


6.2 Commandline parser

There are currently 2 commandline parser modules in the libnix package. You can easily write your own by looking into the examples

libnixmain.a
This is the normal one, i.e. it does all the work necessary for ANSI compatibility and gives you the normal ‘main’ calling convention. You can shut down the commandline parsing (if you want to use the amiga OS commandline parser) by declaring

__nocommandline

somewhere in your code (the type of it actually doesn't matter). This spares some bytes and is compatible to every other compiler.

And you can declare your own WB shell window by declaring a

char __stdiowin[]

variable somewhere in your code (but only if you parse the commandline - without the commandline parser you get no window at all!).

libnix_main.a
This is a special version of a commandline parser - it doesn't call the normal ‘main’ but

int main(char *commandline)

commandline’ is the complete commandline - including the quoted filename of your program (it's only quoted, not escaped - this is for compatibility reasons :-( ). You might think the name of the game should be ‘_main’ and not ‘main’ - and you are completely right. You can use ‘_main’ for ‘main’ and ‘_exit’ for ‘exit’ - there are symbol redirections for these and the linker does the work.

This commandline parser is useful for compatibility. You can use it as a second example or for recompiling PD programs that use the single argument. You cannot use it for compiling ANSI code.