Keil Logo

Technical Support

On-Line Manuals

Compiler User Guide

Preface Overview of the Compiler Getting Started with the Compiler Compiler command-line syntax Compiler command-line options listed by group Default compiler behavior Order of compiler command-line options Using stdin to input source code to the compiler Directing output to stdout Filename suffixes recognized by the compiler Compiler output files Factors influencing how the compiler searches for Compiler command-line options and search paths Compiler search rules and the current place The ARMCC5INC environment variable Code compatibility between separately compiled and Linker feedback during compilation Unused function code Minimizing code size by eliminating unused functio Compilation build time Compilation build time Minimizing compilation build time Minimizing compilation build time with a single ar Effect of --multifile on compilation build time Minimizing compilation build time with parallel ma Compilation build time on Windows Compiler Features Compiler Coding Practices Compiler Diagnostic Messages Using the Inline and Embedded Assemblers of the AR Compiler Command-line Options Language Extensions Compiler-specific Features C and C++ Implementation Details What is Semihosting? Via File Syntax Summary Table of GNU Language Extensions Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

Using stdin to input source code to the compiler

2.5 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.

Procedure

  1. 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.
  2. 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.
  3. Enter your input. For example:
    #include <stdio.h>
    int main(void)
    { printf("Hello world\n"); }
    
  4. Press Ctrl+Z then Return to terminate your input.
An assembly listing for the keyboard input is sent to the output stream after input has been terminated if both the following are true:
  • No output file is specified.
  • No preprocessor-only option is specified, for example -E.
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:
  • armcc -o output.axf - object.o mylibrary.a
  • armcc -o output.axf --c90 source.c -
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.
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.