Coldfire® IAR C/C++ Compiler Reference Guide
Total Page:16
File Type:pdf, Size:1020Kb
ColdFire® IAR C/C++ Compiler Reference Guide for Freescale’s ColdFire Microcontroller Family CCF-2 COPYRIGHT NOTICE © Copyright 2008 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 Systems, IAR Embedded Workbench, C-SPY, visualSTATE, From Idea To Target, IAR KickStart Kit, IAR PowerPac, IAR YellowSuite, IAR Advanced Development Kit, IAR, and the IAR Systems logotype are trademarks or registered trademarks owned by IAR Systems AB. J-Link is a trademark licensed to IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. FreescaleTM and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE Second edition: January 2008 Part number: CCF-2 This guide applies to version 1.x of ColdFire IAR Embedded Workbench®. Internal reference: ISUD. CCF-2 Brief contents Tables .................................................................................................................... xvii Preface ................................................................................................................... xix Part 1. Using the compiler ......................................................... 1 Getting started .................................................................................................... 3 Data storage ...................................................................................................... 11 Functions ............................................................................................................... 21 Placing code and data .................................................................................... 27 The DLIB runtime environment .............................................................. 41 Assembler language interface ................................................................... 69 Using C++ ............................................................................................................ 85 Efficient coding for embedded applications ........................................ 91 Part 2. Reference information ........................................... 107 External interface details ............................................................................ 109 Compiler options ........................................................................................... 115 Data representation ...................................................................................... 141 Compiler extensions .................................................................................... 151 Extended keywords ....................................................................................... 161 Pragma directives ............................................................................................ 171 Intrinsic functions ........................................................................................... 185 The preprocessor ........................................................................................... 189 Library functions ............................................................................................. 195 iii CCF-2 Segment reference ......................................................................................... 203 Implementation-defined behavior .......................................................... 213 Index ..................................................................................................................... 225 ColdFire® IAR C/C++ Compiler iv Reference Guide CCF-2 Contents Tables .................................................................................................................... xvii Preface ................................................................................................................... xix Who should read this guide ..............................................................xix How to use this guide .........................................................................xix What this guide contains ................................................................... xx Other documentation ..........................................................................xxi Further reading ..................................................................................xxi Document conventions ......................................................................xxii Typographic conventions .................................................................xxii Part 1. Using the compiler ......................................................... 1 Getting started .................................................................................................... 3 IAR language overview ........................................................................... 3 Supported ColdFire devices ................................................................. 4 Building applications—an overview .................................................. 4 Compiling ............................................................................................. 4 Linking ................................................................................................ 5 Basic settings for project configuration .......................................... 5 Processor configuration ........................................................................ 6 Code model .......................................................................................... 7 Data model ........................................................................................... 7 Optimization for speed and size ........................................................... 7 Runtime environment ........................................................................... 8 Special support for embedded systems .......................................... 9 Extended keywords .............................................................................. 9 Pragma directives ............................................................................... 10 Predefined symbols ............................................................................ 10 Special function types ........................................................................ 10 Accessing low-level features ............................................................. 10 v CCF-2 Data storage ...................................................................................................... 11 Introduction ............................................................................................. 11 Data models .............................................................................................. 11 Specifying a data model ..................................................................... 12 Memory types .......................................................................................... 13 Near ................................................................................................... 13 Near relative ....................................................................................... 13 Far ..................................................................................................... 14 Using data memory attributes ............................................................ 14 Structures and memory types ............................................................ 15 More examples ................................................................................... 16 C++ and memory types ...................................................................... 16 The stack and auto variables ............................................................. 17 Dynamic memory on the heap ........................................................ 18 Functions ............................................................................................................... 21 Function-related extensions .............................................................. 21 Code models and memory attributes for function storage 21 Using function memory attributes ...................................................... 22 Primitives for interrupts, concurrency, and OS-related programming ............................................................................................ 22 Interrupt functions ............................................................................. 23 Monitor functions ............................................................................... 24 C++ and special function types ......................................................... 25 Placing code and data .................................................................................... 27 Segments and memory