H8 IAR C/C++ Compiler Reference Guide
Total Page:16
File Type:pdf, Size:1020Kb
H8 IAR C/C++ Compiler Reference Guide for Renesas H8/300H and H8S Microcomputer Families CH8-1 COPYRIGHT NOTICE © Copyright 1996–2006 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, From Idea to Target, IAR Embedded Workbench, visualSTATE, IAR MakeApp and C-SPY are trademarks owned by IAR Systems AB. Microsoft and Windows are registered trademarks of Microsoft Corporation. All other product names are trademarks or registered trademarks of their respective owners. EDITION NOTICE First edition: June 2006 Part number: CH8-1 This guide applies to version 2.x of H8 IAR Embedded Workbench®. CH8-1 Brief contents Tables ...................................................................................................................... xv Preface .................................................................................................................. xvii Part 1. Using the compiler ......................................................... 1 Getting started .................................................................................................... 3 Data storage ...................................................................................................... 13 Functions ............................................................................................................... 25 Placing code and data .................................................................................... 33 The DLIB runtime environment ............................................................... 51 Assembler language interface ................................................................... 83 Using C++ .......................................................................................................... 103 Efficient coding for embedded applications ...................................... 117 Part 2. Compiler reference .................................................... 133 Compiler usage ................................................................................................ 135 Compiler options ........................................................................................... 143 Data representation ...................................................................................... 175 Compiler extensions .................................................................................... 187 Extended keywords ....................................................................................... 199 Pragma directives ............................................................................................ 215 Intrinsic functions ........................................................................................... 227 The preprocessor ........................................................................................... 245 Library functions ............................................................................................. 255 iii CH8-1 Segment reference ......................................................................................... 263 Implementation-defined behavior .......................................................... 283 Index ..................................................................................................................... 295 H8 IAR C/C++ Compiler iv Reference Guide CH8-1 Contents Tables ...................................................................................................................... xv Preface .................................................................................................................. xvii Who should read this guide .............................................................xvii How to use this guide ........................................................................xvii What this guide contains ..................................................................xviii Other documentation ..........................................................................xix Further reading ..................................................................................xix Document conventions ........................................................................ xx Typographic conventions ................................................................... xx Part 1. Using the compiler ......................................................... 1 Getting started .................................................................................................... 3 IAR language overview ........................................................................... 3 Supported H8/300H and H8S derivatives ...................................... 4 Building applications—an overview .................................................. 4 Compiling ............................................................................................. 4 Linking ................................................................................................. 4 Basic settings for project configuration .......................................... 5 Core ...................................................................................................... 6 Operating mode .................................................................................... 6 Data model ........................................................................................... 6 Code model .......................................................................................... 7 Hardware configuration ....................................................................... 7 Configuration dependencies ................................................................. 7 Size of double floating-point type ........................................................ 8 Optimization for speed and size ........................................................... 8 Runtime environment ........................................................................... 8 Special support for embedded systems ........................................ 10 Extended keywords ............................................................................ 10 Pragma directives ............................................................................... 10 v CH8-1 Predefined symbols ............................................................................ 10 Special function types ........................................................................ 10 Header files for I/O ............................................................................ 11 Accessing low-level features ............................................................. 11 Data storage ...................................................................................................... 13 Introduction .............................................................................................. 13 Data models .............................................................................................. 14 Specifying a data model ..................................................................... 15 Memory types .......................................................................................... 15 Bitvar .................................................................................................. 16 Data8 memory .................................................................................... 16 Data16 memory .................................................................................. 17 Data32 memory .................................................................................. 17 Using data memory attributes ............................................................ 18 Pointers and memory types ................................................................ 19 Structures and memory types ............................................................ 20 More examples ................................................................................... 20 C++ and memory types ...................................................................... 21 The stack and auto variables ............................................................. 22 Dynamic memory on the heap ........................................................ 23 Functions ............................................................................................................... 25 Function-related extensions .............................................................. 25 Code models and memory attributes for function storage 25 Primitives for interrupts, concurrency, and OS-related programming ............................................................................................ 26 Interrupt functions ............................................................................. 26 Trap functions ..................................................................................