29.10.2014 Views

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

ARM Compiler toolchain v4.1 for µVision Using the Compiler

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Getting started with <strong>the</strong> <strong>Compiler</strong><br />

3.5 <strong>Using</strong> stdin to input source code to <strong>the</strong> compiler<br />

Instead of creating a file <strong>for</strong> your source code, you can use stdin to input source code directly<br />

on <strong>the</strong> command line. This is useful if you want to test a short piece of code without having to<br />

create a file <strong>for</strong> it.<br />

To use stdin to input source code directly on <strong>the</strong> command line:<br />

1. Invoke <strong>the</strong> compiler with <strong>the</strong> command-line options you want to use. The default compiler<br />

mode is C. Use <strong>the</strong> minus character (-) as <strong>the</strong> source filename to instruct <strong>the</strong> compiler to<br />

take input from stdin. For example:<br />

armcc --bigend -c -<br />

If you want an object file to be written, use <strong>the</strong> -o option. If you want preprocessor output<br />

to be sent to <strong>the</strong> output stream, use <strong>the</strong> -E option. If you want <strong>the</strong> output to be sent to<br />

stdout, use <strong>the</strong> -o- option. If you want an assembly listing of <strong>the</strong> keyboard input to be sent<br />

to <strong>the</strong> output stream after input has been terminated, use none of <strong>the</strong>se options.<br />

2. You cannot input on <strong>the</strong> same line after <strong>the</strong> minus character. You must press <strong>the</strong> return key<br />

if you have not already done so.<br />

The command prompt waits <strong>for</strong> you to enter more input.<br />

3. Enter your input. For example:<br />

#include <br />

int main(void)<br />

{ printf("Hello world\n"); }<br />

4. Terminate your input by entering Ctrl-Z <strong>the</strong>n Return.<br />

An assembly listing <strong>for</strong> <strong>the</strong> keyboard input is sent to <strong>the</strong> output stream after input has been<br />

terminated if both <strong>the</strong> following are true:<br />

• no output file is specified<br />

• no preprocessor-only option is specified, <strong>for</strong> example -E.<br />

O<strong>the</strong>rwise, an object file is created or preprocessor output is sent to <strong>the</strong> standard output stream,<br />

depending on whe<strong>the</strong>r you used <strong>the</strong> -o option or <strong>the</strong> -E option.<br />

The compiler accepts source code from <strong>the</strong> standard input stream in combination with o<strong>the</strong>r<br />

files, when per<strong>for</strong>ming a link step. For example, <strong>the</strong> following are permitted:<br />

• armcc -o output.axf - object.o mylibrary.a<br />

• armcc -o output.axf --c90 source.c -<br />

Executing <strong>the</strong> following command compiles <strong>the</strong> source code you provide on standard input, and<br />

links it into test.axf:<br />

armcc -o test.axf -<br />

You can only combine standard input with o<strong>the</strong>r source files when you are linking code. If you<br />

attempt to combine standard input with o<strong>the</strong>r source files when not linking, <strong>the</strong> compiler<br />

generates an error.<br />

3.5.1 See also<br />

Tasks<br />

Introducing <strong>the</strong> <strong>ARM</strong> <strong>Compiler</strong> <strong>toolchain</strong>:<br />

• <strong>Using</strong> a text file to specify command-line options on page 2-20.<br />

<strong>ARM</strong> DUI 0375C Copyright © 2007-2008, 2011 <strong>ARM</strong>. All rights reserved. 3-11<br />

ID061811<br />

Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!