| |||
| Home > Standard C Implementation Definition > Implementation definition > Environment | |||
The mapping of a command line from the ARM architecture-based
environment into arguments to main() is implementation-specific.
The generic ARM C library supports the following:
The arguments given to main() are the
words of the command line (not including input/output redirections),
delimited by whitespace, except where the whitespace is contained
in double quotes.
A whitespace character is any
character where the result of isspace() is
true.
A double quote or backslash character \ inside
double quotes must be preceded by a backslash character.
An input/output redirection is not recognized inside double quotes.
In an nonhosted implementation of the ARM C library, the term interactive
device might be meaningless. The generic ARM C library
supports a pair of devices, both called :tt,
intended to handle keyboard input and VDU screen output. In the
generic implementation:
no buffering is done on any
stream connected to :tt unless input/output redirection
has occurred
if input/output redirection other than to :tt has
occurred, full file buffering is used (except that line buffering
is used if both stdout and stderr were
redirected to the same file).
Using the generic ARM C library, the standard input (stdin),
output (stdout) and error streams (stderr)
can be redirected at runtime. For example, if mycopy is
a program, running on a host debugger, that 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:
stdinThe file
is redirected to infile.
stdoutThe
file is redirected to outfile.
stderrThe
file is redirected to errfile.
The permitted redirections are:
0< filenameThis reads stdin from .filename
< filenameThis reads stdin from .filename
1> filenameThis writes stdout to .filename
> filenameThis writes stdout from .filename
2> filenameThis writes stderr from .filename
2>&1This
writes stderr to the same place as stdout.
>& fileThis writes both stdout and stderr to .filename
>> filenameThis appends stdout to .filename
>>& filenameThis appends both stdout and stderr to .filename
To redirect stdin, stdout,
and stderr on the target, you must define:
#pragma import(_main_redirection)
File redirection is done only if either:
the invoking operating system supports it
the program reads and writes characters and has
not replaced the C library functions fputc() and fgetc().