3.3.2. Environment

The mapping of a command line from the ARM-based environment into arguments to main() is implementation-specific. The generic ARM C library supports the following:

main()

The arguments given to main() are the words of the command line (not including I/O redirections), delimited by white space, except where the white space is contained in double quotes.

Note that:

  • a whitespace character is any character of which isspace() is true

  • a double quote or backslash character (\) inside double quotes must be preceded by a backslash character

  • an I/O redirection will not be recognized inside double quotes.

Interactive device

In an unhosted implementation of the ARM C library, the term interactive device may be meaningless. The generic ARM C library supports a pair of devices, both called :tt, intended to handle a keyboard and a VDU screen. In the generic implementation:

  • no buffering is done on any stream connected to :tt unless I/O redirection has taken place

  • if I/O redirection other than to :tt has taken place, full file buffering is used (except where both stdout and stderr have been redirected to the same file, where line buffering is used).

Standard input, output and error streams

Using the generic ARM C library, the standard input, output and error streams stdin, stdout, and stderr can be redirected at runtime. For example, if mycopy is a program which simply copies the standard input to the standard output, the following line runs the program:

mycopy < infile > outfile 2> errfile

and redirects the files as follows:

stdin

is redirected to infile

stdout

is redirected to outfile

stderr

is redirected to errfile

The following shows the permitted redirections:

0< filename

reads stdin from filename

< filename

reads stdin from filename

1> filename

writes stdout to filename

> filename

writes stdout to filename

2> filename

writes stderr to filename

2>&1

writes stderr to the same place as stdout

>& filename

writes both stdout and stderr to filename

>> filename

appends stdout to filename

>>& filename

appends both stdout and stderr to filename

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0041C