ARM® IAR C/C++ Compiler Reference Guide
Total Page:16
File Type:pdf, Size:1020Kb
ARM® IAR C/C++ Compiler Reference Guide for Advanced RISC Machines Ltd’s ARM Cores CARM-10 COPYRIGHT NOTICE © Copyright 1999–2004 IAR Systems. All rights reserved. No part of this document may be reproduced without the prior written consent of IAR Systems. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. DISCLAIMER The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. TRADEMARKS IAR, IAR Embedded Workbench, IAR XLINK Linker, IAR XAR Library Builder, IAR XLIB Librarian, IAR MakeApp, and IAR PreQual are trademarks owned by IAR Systems. C-SPY is a trademark registered in Sweden by IAR Systems. IAR visualSTATE is a registered trademark owned by IAR Systems. ARM and Thumb are registered trademarks of Advanced RISC Machines Ltd. Microsoft and Windows are registered trademarks of Microsoft Corporation. Intel and Pentium are registered trademarks and XScale a trademark of Intel Corporation. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE Tenth edition: February 2004 Part number: CARM-10 This guide applies to version 4.x of the ARM IAR Embedded Workbench™. CARM-10 Brief contents Tables ..................................................................................................................... xiii Preface .................................................................................................................... xv Part 1. Using the compiler ......................................................... 1 Getting started .................................................................................................... 3 Data storage ...................................................................................................... 11 Functions ............................................................................................................. 15 Placing code and data .................................................................................... 23 The DLIB runtime environment ............................................................... 37 Assembler language interface ................................................................... 67 Using C++ ............................................................................................................ 83 Efficient coding for embedded applications ........................................ 87 Part 2. Compiler reference .................................................... 101 Data representation ...................................................................................... 103 Segment reference ......................................................................................... 113 Compiler options ........................................................................................... 121 Extended keywords ....................................................................................... 147 Pragma directives ............................................................................................ 153 Predefined symbols ........................................................................................ 165 Intrinsic functions ........................................................................................... 171 Library functions ............................................................................................. 177 Implementation-defined behavior .......................................................... 183 iii CARM-10 IAR language extensions ............................................................................. 195 Diagnostics ......................................................................................................... 207 Index ..................................................................................................................... 209 ARM® IAR C/C++ Compiler iv Reference Guide CARM-10 Contents Tables ..................................................................................................................... xiii Preface .................................................................................................................... xv Who should read this guide ............................................................... xv How to use this guide .......................................................................... xv What this guide contains ....................................................................xvi Other documentation .........................................................................xvii Further reading .................................................................................xvii Document conventions .....................................................................xviii Typographic conventions ................................................................xviii Part 1. Using the compiler ......................................................... 1 Getting started .................................................................................................... 3 IAR language overview ........................................................................... 3 Building applications—an overview .................................................. 4 Compiling ............................................................................................. 4 Linking ................................................................................................. 4 Basic settings for project configuration .......................................... 5 Processor variant .................................................................................. 5 CPU mode ............................................................................................ 6 Interworking ......................................................................................... 6 VFP and floating-point arithmetic ....................................................... 7 Byte order ............................................................................................. 7 Optimization for speed and size ........................................................... 7 Runtime environment ........................................................................... 8 Special support for embedded systems .......................................... 9 Extended keywords .............................................................................. 9 Predefined symbols ............................................................................ 10 Special function types ........................................................................ 10 Header files for I/O ............................................................................ 10 Accessing low-level features ............................................................. 10 v CARM-10 Data storage ...................................................................................................... 11 Introduction .............................................................................................. 11 The stack and auto variables ............................................................. 11 Dynamic memory on the heap ........................................................ 13 Functions ............................................................................................................. 15 ARM and Thumb code ........................................................................ 15 Keywords for functions ........................................................................ 15 Execution in RAM ................................................................................... 16 Interrupt functions ................................................................................. 17 Interrupts and fast interrupts .............................................................. 17 Nested interrupts ................................................................................ 18 Software interrupts ............................................................................. 19 Installing interrupt functions .............................................................. 20 Interrupt operations ............................................................................ 20 Monitor functions ............................................................................... 21 C++ and special function types ......................................................... 22 Function directives ................................................................................. 22 Placing code and data .................................................................................... 23 Segments and memory ........................................................................ 23 What is a segment? ............................................................................ 23 Placing segments in memory ............................................................ 24 Customizing the linker command file ................................................ 25 Data segments