Using stdin to
input source code to the compiler
Instead of creating a file for your source code, you can use stdin to
input source code directly on the command line. This is useful if
you want to test a short piece of code without having to create
a file for it.
To use stdin to input source code directly
on the command line:
Invoke the compiler with the command-line
options you want to use. The default compiler mode is C. Use the
minus character (-) as the source filename to
instruct the compiler to take input from stdin.
For example:
armcc --bigend -c -
If you want an object file to be written, use the -o option.
If you want preprocessor output to be sent to the output stream,
use the -E option. If you want the output to be
sent to stdout, use the -o- option.
If you want an assembly listing of the keyboard input to be sent to
the output stream after input has been terminated, use none of these
options.
You cannot input on the same line after the minus
character. You must press the return key if you have not already
done so.
The command prompt waits for you to enter more input.
Enter your input. For example:
#include <stdio.h>
int main(void)
{ printf("Hello world\n"); }
On Microsoft Windows systems, terminate your input
by entering Ctrl-Z then Return.
An assembly listing for the keyboard input is sent to the
output stream after input has been terminated if both the following
are true:
Otherwise, an object file is created or preprocessor output
is sent to the standard output stream, depending on whether you
used the -o option or the -E option.
The compiler accepts source code from the standard input stream
in combination with other files, when performing a link step. For
example, the following are permitted:
Executing the following command compiles the source code you
provide on standard input, and links it into test.axf:
armcc -o test.axf -
You can only combine standard input with other source files
when you are linking code. If you attempt to combine standard input
with other source files when not linking, the compiler generates
an error.
See also
- Tasks
Introducing the ARM Compiler toolchain:
- Reference
Introducing the ARM Compiler toolchain: