EWARM DevelopmentGuide - ENU
EWARM DevelopmentGuide - ENU
COPYRIGHT NOTICE
Copyright 19992009 IAR Systems AB. No part of this document may be reproduced without the prior written consent of IAR Systems AB. 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. ARM, Thumb, and Cortex are registered trademarks of Advanced RISC Machines Ltd. All other product names are trademarks or registered trademarks of their respective owners.
EDITION NOTICE
Fourth edition: June 2009 Part number: DARM-4 This guide applies to version 5.4x of IAR Embedded Workbench for ARM. The IAR C/C++ Development Guide for ARM replaces all versions of the ARM IAR C/C++ Compiler Reference Guide and the IAR Linker and Library Tools Reference Guide. Internal reference: R10, 5.5.x, ISUD.
Brief contents
Tables
.................................................................................................................. xxvii ................................................................................................................. xxix ..................................................... 1
Preface
.......................................................... 3
................................................................... 91
Application-related considerations
........................................... 145
............................................................................ 147
........................................................................................... 155
....................................................................................... 233
iii
Implementation-defined behavior
.............................................................................................................. 361
..................................................................................................................... 377
iv
Contents
Tables
.................................................................................................................. xxvii ................................................................................................................. xxix
Preface
Who should read this guide ............................................................ xxix How to use this guide ....................................................................... xxix What this guide contains ................................................................. xxx Other documentation ........................................................................ xxxi
Further reading ...............................................................................xxxii
..................................................... 1
.......................................................... 3
Data storage
...................................................................................................... 25
Introduction ............................................................................................. 25
Different ways to store data ............................................................... 25
Functions
............................................................................................................... 29
Function-related extensions .............................................................. 29 ARM and Thumb code ........................................................................ 29 Execution in RAM ................................................................................... 30
vi
Contents
........................................................................................ 39
Linkingan overview ............................................................................ 39 Modules and sections ............................................................................ 40 The linking process ................................................................................ 41 Placing code and datathe linker configuration file .............. 42
A simple example of a configuration file ........................................... 43
................................................................................ 47
vii
.............................................................. 61
Overriding library modules ............................................................... 69 Building and using a customized library ....................................... 71
Setting up a library project ................................................................. 71 Modifying the library functionality .................................................... 71 Using a customized library ................................................................ 72
viii
Contents
Locale ........................................................................................................... 81
Locale support in prebuilt libraries .................................................... 81 Customizing the locale support .......................................................... 82 Changing locales at runtime .............................................................. 83
Signal and raise ........................................................................................ 84 Time ............................................................................................................. 85 Strtod ........................................................................................................... 85 Assert ........................................................................................................... 85 Atexit ........................................................................................................... 86 C-SPY runtime interface .................................................................... 86
Low-level debugger runtime interface ............................................... 86 The debugger terminal I/O window ................................................... 87
................................................................... 91
ix
Using C++
.......................................................................................................... 107
Application-related considerations
....................................................... 115
Heap considerations ............................................................................ 117 Interaction between the tools and your application ............. 117 Checksum calculation ......................................................................... 119
Calculating a checksum ................................................................... 120 Adding a checksum function to your source code ........................... 121 Things to remember ......................................................................... 122 C-SPY considerations ...................................................................... 122
Contents
...................................... 127
xi
........................................... 145
............................................................................ 147
Include file search procedure .......................................................... 149 Compiler output ................................................................................... 150 ILINK output .......................................................................................... 151 Diagnostics .............................................................................................. 152
Message format for the compiler ..................................................... 152 Message format for the linker .......................................................... 152 Severity levels .................................................................................. 153 Setting the severity level .................................................................. 153 Internal error .................................................................................... 154
Compiler options
........................................................................................... 155
xii
Contents
--diag_error ...................................................................................... 166 --diag_remark ................................................................................... 166 --diag_suppress ................................................................................ 167 --diag_warning ................................................................................. 167 --diagnostics_tables .......................................................................... 167 --discard_unused_publics ................................................................. 168 --dlib_config .................................................................................... 168 -e ...................................................................................................... 169 --ec++ ............................................................................................... 169 --eec++ ............................................................................................. 169 --enable_hardware_workaround ...................................................... 170 --enable_multibytes .......................................................................... 170 --endian ............................................................................................ 170 --enum_is_int ................................................................................... 171 --error_limit ...................................................................................... 171 -f ....................................................................................................... 171 --fpu .................................................................................................. 172 --header_context ............................................................................... 172 -I ....................................................................................................... 173 --interwork ....................................................................................... 173 -l ....................................................................................................... 173 --legacy ............................................................................................. 174 --mfc ................................................................................................. 175 --migration_preprocessor_extensions .............................................. 175 --no_clustering ................................................................................. 176 --no_code_motion ............................................................................ 176 --no_const_align ............................................................................... 176 --no_cse ............................................................................................ 177 --no_fragments ................................................................................. 177 --no_guard_calls ............................................................................... 177 --no_inline ........................................................................................ 178 --no_path_in_file_macros ................................................................ 178 --no_scheduling ................................................................................ 178 --no_tbaa .......................................................................................... 179
xiii
--no_typedefs_in_diagnostics .......................................................... 179 --no_unaligned_access ..................................................................... 180 --no_unroll ....................................................................................... 180 --no_warnings .................................................................................. 181 --no_wrap_diagnostics ..................................................................... 181 -O ..................................................................................................... 181 -o, --output ....................................................................................... 182 --only_stdout .................................................................................... 182 --output, -o ....................................................................................... 183 --predef_macros ............................................................................... 183 --preinclude ...................................................................................... 183 --preprocess ...................................................................................... 184 --public_equ ..................................................................................... 184 -r, --debug ......................................................................................... 185 --remarks .......................................................................................... 185 --require_prototypes ......................................................................... 185 --section ............................................................................................ 186 --separate_cluster_for_initialized_variables .................................... 186 --silent .............................................................................................. 187 --strict_ansi ....................................................................................... 187 --thumb ............................................................................................. 187 --use_unix_directory_separators ...................................................... 188 --warnings_affect_exit_code ............................................................ 188 --warnings_are_errors ...................................................................... 188
Linker options
.................................................................................................. 189
xiv
Contents
--define_symbol ............................................................................... 193 --diag_error ...................................................................................... 194 --diag_remark ................................................................................... 194 --diag_suppress ................................................................................ 195 --diag_warning ................................................................................. 195 --diagnostics_tables .......................................................................... 196 --entry ............................................................................................... 196 --error_limit ...................................................................................... 196 --export_builtin_config .................................................................... 197 -f ....................................................................................................... 197 --force_output ................................................................................... 197 --image_input ................................................................................... 198 --keep ............................................................................................... 198 --log .................................................................................................. 199 --log_file ........................................................................................... 199 --mangled_names_in_messages ....................................................... 199 --map ................................................................................................ 200 --no_fragments ................................................................................. 200 --no_library_search .......................................................................... 201 --no_locals ........................................................................................ 201 --no_remove ..................................................................................... 201 --no_veneers ..................................................................................... 202 --no_warnings .................................................................................. 202 --no_wrap_diagnostics ..................................................................... 202 -o, --output ....................................................................................... 202 --only_stdout .................................................................................... 203 --ose_load_module ........................................................................... 203 --output, -o ....................................................................................... 203 --pi_veneers ...................................................................................... 204 --place_holder .................................................................................. 204 --redirect ........................................................................................... 205 --remarks .......................................................................................... 205 --semihosting .................................................................................... 205 --silent .............................................................................................. 206
xv
Data representation
...................................................................................... 209
Compiler extensions
.................................................................................... 221
Extended keywords
....................................................................................... 233
xvi
Contents
Summary of extended keywords ................................................... 236 Descriptions of extended keywords ............................................. 237
__arm ............................................................................................... 237 __big_endian .................................................................................... 237 __fiq ................................................................................................. 237 __interwork ...................................................................................... 238 __intrinsic ........................................................................................ 238 __irq ................................................................................................. 238 __little_endian ................................................................................. 238 __nested ........................................................................................... 239 __no_init .......................................................................................... 239 __noreturn ........................................................................................ 239 __packed .......................................................................................... 240 __ramfunc ........................................................................................ 240 __root ............................................................................................... 241 __swi ................................................................................................ 241 __task ............................................................................................... 242 __thumb ........................................................................................... 243 __weak ............................................................................................. 243
xvii
location ............................................................................................. 251 message ............................................................................................ 252 object_attribute ................................................................................. 252 optimize ............................................................................................ 252 pack ................................................................................................. 253 __printf_args .................................................................................... 254 required ............................................................................................ 254 rtmodel ............................................................................................. 255 __scanf_args .................................................................................... 256 section .............................................................................................. 256 swi_number ...................................................................................... 257 type_attribute ................................................................................... 257 weak ................................................................................................. 258
Intrinsic functions
........................................................................................... 259
Summary of intrinsic functions ....................................................... 259 Descriptions of intrinsic functions ................................................. 262
__CLZ .............................................................................................. 262 __disable_fiq .................................................................................... 262 __disable_interrupt .......................................................................... 263 __disable_irq .................................................................................... 263 __DMB ............................................................................................ 263 __DSB .............................................................................................. 263 __enable_fiq .................................................................................... 264 __enable_interrupt ........................................................................... 264 __enable_irq .................................................................................... 264 __get_BASEPRI .............................................................................. 264 __get_CONTROL ............................................................................ 264 __get_CPSR ..................................................................................... 265 __get_FAULTMASK ...................................................................... 265 __get_interrupt_state ....................................................................... 265 __get_PRIMASK ............................................................................. 265 __ISB ............................................................................................... 266 __LDC ............................................................................................. 266
xviii
Contents
__LDCL ........................................................................................... 266 __LDC2 ........................................................................................... 266 __LDC2L ......................................................................................... 266 __LDC_noidx .................................................................................. 266 __LDCL_noidx ................................................................................ 266 __LDC2_noidx ................................................................................ 266 __LDC2L_noidx .............................................................................. 266 __LDREX ........................................................................................ 267 __MCR ............................................................................................ 267 __MRC ............................................................................................ 268 __no_operation ................................................................................ 268 __QADD .......................................................................................... 268 __QADD8 ........................................................................................ 268 __QADD16 ...................................................................................... 269 __QASX .......................................................................................... 269 __QDADD ....................................................................................... 269 __QDOUBLE .................................................................................. 269 __QDSUB ........................................................................................ 270 __QFlag ........................................................................................... 270 __QSUB ........................................................................................... 270 __QSUB8 ......................................................................................... 270 __QSUB16 ....................................................................................... 270 __QSAX .......................................................................................... 271 __REV ............................................................................................. 271 __REVSH ........................................................................................ 271 __SADD8 ........................................................................................ 271 __SADD16 ...................................................................................... 271 __SASX ........................................................................................... 272 __SEL .............................................................................................. 272 __set_BASEPRI .............................................................................. 272 __set_CONTROL ............................................................................ 272 __set_CPSR ..................................................................................... 273 __set_FAULTMASK ...................................................................... 273 __set_interrupt_state ........................................................................ 273
xix
__set_PRIMASK ............................................................................. 273 __SHADD8 ...................................................................................... 273 __SHADD16 .................................................................................... 274 __SHASX ........................................................................................ 274 __SHSUB8 ...................................................................................... 274 __SHSUB16 .................................................................................... 274 __SHSAX ........................................................................................ 274 __SMUL .......................................................................................... 275 __SSUB8 ......................................................................................... 275 __SSUB16 ....................................................................................... 275 __SSAX ........................................................................................... 275 __STC .............................................................................................. 276 __STCL ............................................................................................ 276 __STC2 ............................................................................................ 276 __STC2L .......................................................................................... 276 __STC_noidx ................................................................................... 276 __STCL_noidx ................................................................................ 276 __STC2_noidx ................................................................................. 276 __STC2L_noidx .............................................................................. 276 __STREX ......................................................................................... 277 __SWP ............................................................................................. 277 __SWPB .......................................................................................... 277 __UADD8 ........................................................................................ 277 __UADD16 ...................................................................................... 277 __UASX .......................................................................................... 278 __UHADD8 ..................................................................................... 278 __UHADD16 ................................................................................... 278 __UHASX ........................................................................................ 278 __UHSAX ........................................................................................ 278 __UHSUB8 ...................................................................................... 279 __UHSUB16 .................................................................................... 279 __UQADD8 ..................................................................................... 279 __UQADD16 ................................................................................... 279 __UQASX ........................................................................................ 280
xx
Contents
__UQSUB8 ...................................................................................... 280 __UQSUB16 .................................................................................... 280 __UQSAX ........................................................................................ 280 __USAX .......................................................................................... 280 __USUB8 ......................................................................................... 281 __USUB16 ....................................................................................... 281
Library functions
............................................................................................. 289
...................................................................... 297
xxi
xxii
Contents
IRQ_STACK .................................................................................... 322 .noinit ............................................................................................... 322 .rodata ............................................................................................... 322 .text ................................................................................................... 322
IAR utilities
........................................................................................................ 323
xxiii
xxiv
Contents
Implementation-defined behavior
.......................................................... 349
Glossary Index
.............................................................................................................. 361
..................................................................................................................... 377
xxv
xxvi
Tables
1: Typographic conventions used in this guide .................................................... xxxiii 2: Naming conventions used in this guide ........................................................... xxxiv 3: Command line options for specifying library and dependency files ..................... 23 4: Sections holding initialized data ........................................................................... 45 5: Description of a relocation error ........................................................................... 58 6: Library configurations ........................................................................................... 63 7: Customizable items ............................................................................................... 66 8: Formatters for printf .............................................................................................. 68 9: Formatters for scanf .............................................................................................. 69 10: Descriptions of printf configuration symbols ..................................................... 79 11: Descriptions of scanf configuration symbols ...................................................... 80 12: Low-level I/O files .............................................................................................. 81 13: Functions with special meanings when linked with debug info ......................... 86 14: Example of runtime model attributes .................................................................. 88 15: Registers used for passing parameters .............................................................. 100 16: Registers used for returning values ................................................................... 101 17: Call frame information resources defined in a names block ............................. 104 18: Exception stacks ................................................................................................ 116 19: Compiler optimization levels ............................................................................ 135 20: Compiler environment variables ....................................................................... 148 21: ILINK environment variables ........................................................................... 149 22: Error return codes .............................................................................................. 151 23: Compiler options summary ............................................................................... 158 24: Linker options summary ................................................................................... 189 25: Integer types ...................................................................................................... 210 26: Floating-point types .......................................................................................... 213 27: Section operators and their symbols ................................................................. 224 28: Extended keywords summary ........................................................................... 236 29: Pragma directives summary .............................................................................. 245 30: Intrinsic functions summary .............................................................................. 259 31: Predefined symbols ........................................................................................... 284
xxvii
32: Values for specifying different CPU core families in __TID__ ....................... 286 33: Traditional standard C header filesDLIB ...................................................... 291 34: Embedded C++ header files .............................................................................. 292 35: Additional Embedded C++ header filesDLIB ............................................... 292 36: Standard template library header files ............................................................... 293 37: New standard C header filesDLIB ................................................................ 293 38: Section summary ............................................................................................... 319 39: iarchive parameters ........................................................................................... 324 40: iarchive commands summary ............................................................................ 324 41: iarchive options summary ................................................................................. 325 42: ielftool parameters ............................................................................................. 331 43: ielftool options summary ................................................................................... 331 44: ielfdumparm parameters .................................................................................... 336 45: ielfdumparm options summary ......................................................................... 336 46: iobjmanip parameters ........................................................................................ 339 47: iobjmanip options summary .............................................................................. 339 48: ielftool parameters ............................................................................................. 344 49: isymexport options summary ............................................................................ 344 50: Message returned by strerror()IAR DLIB library ......................................... 359
Preface
Welcome to the IAR C/C++ Development Guide for ARM. The purpose of this guide is to provide you with detailed reference information that can help you to use the build tools to best suit your application requirements. This guide also gives you suggestions on coding techniques so that you can develop applications with maximum efficiency.
The architecture and instruction set of the ARM core. Refer to the documentation from Advanced RISC Machines Ltd for information about the ARM core The C or C++ programming language Application development for embedded systems The operating system of your host computer.
xxix
Introduction to the IAR build tools gives an introduction to the IAR build tools, which includes an overview of the tools, the programming languages, the available device support, and extensions provided for supporting specific features of the ARM core. Developing embedded applications gives the information you need to get started developing your embedded software using the IAR build tools. Data storage describes how to store data in memory. Functions gives a brief overview of function-related extensionsmechanisms for controlling functionsand describes some of these mechanisms in more detail. Linking using ILINK describes the linking process using the IAR ILINK Linker and the related concepts. Linking your application lists aspects that you must consider when linking your application, including using ILINK options and tailoring the linker configuration file. The DLIB runtime environment describes the DLIB runtime environment in which an application executes. It covers how you can modify it by setting options, overriding default library modules, or building your own library. The chapter also describes system initialization introducing the file cstartup, how to use modules for locale, and file I/O. Assembler language interface contains information required when parts of an application are written in assembler language. This includes the calling convention. Using C++ gives an overview of the two levels of C++ support: The industry-standard EC++ and IAR Extended EC++. Application-related considerations discusses a selected range of application issues related to using the compiler and linker. Efficient coding for embedded applications gives hints about how to write code that compiles to efficient code for an embedded application.
External interface details provides reference information about how the compiler and linker interact with their environmentthe invocation syntax, methods for passing options to the compiler and linker, environment variables, the include file search procedure, and the different types of compiler and linker output. The chapter also describes how the diagnostic system works.
xxx
Preface
Compiler options explains how to set options, gives a summary of the options, and contains detailed reference information for each compiler option. Linker options gives a summary of the options, and contains detailed reference information for each linker option. Data representation describes the available data types, pointers, and structure types. This chapter also gives information about type and object attributes. Compiler extensions gives a brief overview of the compiler extensions to the ISO/ANSI C standard. More specifically the chapter describes the available C language extensions. Extended keywords gives reference information about each of the ARM-specific keywords that are extensions to the standard C/C++ language. Pragma directives gives reference information about the pragma directives. Intrinsic functions gives reference information about functions to use for accessing ARM-specific low-level features. The preprocessor gives a brief overview of the preprocessor, including reference information about the different preprocessor directives, symbols, and other related information. Library functions gives an introduction to the C or C++ library functions, and summarizes the header files. The linker configuration file describes the purpose of the linker configuration file and describes its contents. Section reference gives reference information about the use of sections. IAR utilities describes the IAR utilities that handle the ELF and DWARF object formats. Implementation-defined behavior describes how the compiler handles the implementation-defined areas of the C language standard.
Glossary
The glossary contains definitions of programming terms.
Other documentation
The complete set of IAR Systems development tools for the ARM core is described in a series of guides. For information about:
Using the IDE and the IAR C-SPY Debugger, refer to the IAR Embedded Workbench IDE User Guide for ARM Programming for the ARM IAR Assembler, refer to the ARM IAR Assembler Reference Guide
xxxi
Other documentation
Using the IAR DLIB Library functions, refer to the online help system Porting application code and projects created with a previous IAR Embedded Workbench for ARM, refer to the ARM IAR Embedded Workbench Migration Guide Using the MISRA-C:1998 rules or the MISRA-C:2004 rules, refer to the IAR Embedded Workbench MISRA C:1998 Reference Guide or the IAR Embedded Workbench MISRA C:2004 Reference Guide, respectively.
All of these guides are delivered in hypertext PDF or HTML format on the installation media. Some of them are also delivered as printed books.
FURTHER READING
These books might be of interest to you when using the IAR Systems development tools:
Seal, David, and David Jagger. ARM Architecture Reference Manual. Addison-Wesley. Barr, Michael, and Andy Oram, ed. Programming Embedded Systems in C and C++ . OReilly & Associates. Furber, Steve, ARM System-on-Chip Architecture. Addison-Wesley. Harbison, Samuel P. and Guy L. Steele (contributor). C: A Reference Manual. Prentice Hall. Kernighan, Brian W. and Dennis M. Ritchie. The C Programming Language. Prentice Hall. [The later editions describe the ANSI C standard.] Labrosse, Jean J. Embedded Systems Building Blocks: Complete and Ready-To-Use Modules in C. R&D Books. Lippman, Stanley B. and Jose Lajoie. C++ Primer. Addison-Wesley. Mann, Bernhard. C fr Mikrocontroller. Franzis-Verlag. [Written in German.] Sloss, Andrew N. et al, ARM System Developer's Guide: Designing and Optimizing System Software. Morgan Kaufmann. Stroustrup, Bjarne. The C++ Programming Language. Addison-Wesley.
The Advanced RISC Machines Ltd web site, www.arm.com, contains information and news about the ARM cores, as well as information about the ARM Embedded Application Binary Interface (AEABI). The IAR Systems web site, www.iar.com, holds application notes and other product information. The web site www.SevensAndNines.com, maintained by IAR Systems, provides an online user community and resource site for ARM developers.
xxxii
Preface
Finally, the Embedded C++ Technical Committee web site, www.caravan.net/ec2plus, contains information about the Embedded C++ standard.
Document conventions
When, in this text, we refer to the programming language C, the text also applies to C++, unless otherwise stated. When referring to a directory in your product installation, for example arm\doc, the full path to the location is assumed, for example c:\Program Files\IAR Systems\Embedded Workbench 5.n\arm\doc.
TYPOGRAPHIC CONVENTIONS
This guide uses the following typographic conventions:
Style Used for
computer
Source code examples and file paths. Text on the command line. Binary, hexadecimal, and octal numbers. A placeholder for an actual value used as a parameter, for example filename.h where filename represents the name of the file. An optional part of a command, where [] is part of the described syntax. A mandatory part of a command, where {} is part of the described syntax. An optional part of a command. Alternatives in a command. A mandatory part of a command with alternatives. Names of menus, menu commands, buttons, and dialog boxes that appear on the screen. A cross-reference within this guide or to another guide. Emphasis. An ellipsis indicates that the previous item can be repeated an arbitrary number of times. Identifies instructions specific to the IAR Embedded Workbench IDE interface. Identifies instructions specific to the command line interface.
parameter
[option] {option}
[option] a|b|c {a|b|c} bold italic
xxxiii
Document conventions
Style
Used for
NAMING CONVENTIONS
The following naming conventions are used for the products and tools from IAR Systems referred to in this guide:
Brand name Generic term
IAR Embedded Workbench for ARM IAR Embedded Workbench IDE for ARM IAR C-SPY Debugger for ARM IAR C-SPY Simulator IAR C/C++ Compiler for ARM IAR Assembler for ARM IAR ILINK Linker IAR DLIB Library
Table 2: Naming conventions used in this guide
IAR Embedded Workbench the IDE C-SPY, the debugger the simulator the compiler the assembler ILINK, the linker the DLIB library
Introduction to the IAR build tools Developing embedded applications Data storage Functions Linking using ILINK Linking your application The DLIB runtime environment Assembler language interface Using C++ Application-related considerations Efficient coding for embedded applications.
The IAR build toolsthe build interfaces, compiler, assembler, and linker The programming languages The available device support The extensions provided by the IAR C/C++ Compiler for ARM to support specific features of the ARM core.
IAR ASSEMBLER
The IAR Assembler for ARM is a powerful relocating macro assembler with a versatile set of directives and expression operators. The assembler features a built-in C language preprocessor and supports conditional assembly. The IAR Assembler for ARM uses the same mnemonics and operand syntax as the Advanced RISC Machines Ltd ARM Assembler, which simplifies the migration of existing code. For detailed information, see the ARM IAR Assembler Reference Guide.
The IAR Archive Tooliarchivecreates and manipulates a library (archive) of several ELF object files The IAR ELF Toolielftoolperforms various transformations on an ELF executable image (such as, fill, checksum, format conversion etc) The IAR ARM ELF Dumperielfdumparmcreates a text representation of the contents of an ELF relocatable or executable image The IAR ELF Object Tooliobjmanipis used for performing low-level manipulation of ELF object files The IAR Absolute Symbol Exporterisymexportexports absolute symbols from a ROM image file, so that they can be used when linking an add-on application.
Note: These ELF utilities are well-suited for object files produced by the tools from IAR Systems. Thus, we recommend using them instead of the GNU binary utilities.
EXTERNAL TOOLS
For information about how to extend the tool chain in the IDE, see the IAR Embedded Workbench IDE User Guide for ARM.
C, the most widely used high-level programming language in the embedded systems industry. Using the IAR C/C++ Compiler for ARM, you can build freestanding applications that follow the standard ISO 9899:1990. This standard is commonly known as ANSI C. C++, a modern object-oriented programming language with a full-featured library well suited for modular programming. IAR Systems supports two levels of the C++ language:
Embedded C++ (EC++), a subset of the C++ programming standard, which is intended for embedded systems programming. It is defined by an industry consortium, the Embedded C++ Technical committee. See the chapter Using C++. IAR Extended Embedded C++, with additional features such as full template support, multiple inheritance, namespace support, the new cast operators, as well as the Standard Template Library (STL).
Each of the supported languages can be used in strict or relaxed mode, or relaxed with IAR extensions enabled. The strict mode adheres to the standard, whereas the relaxed mode allows some deviations from the standard. For more details, see the chapter Compiler extensions. For information about how the compiler handles the implementation-defined areas of the C language, see the chapter Implementation-defined behavior. It is also possible to implement parts of the application, or the whole application, in assembler language. See the ARM IAR Assembler Reference Guide. For more information about the Embedded C++ language and Extended Embedded C++, see the chapter Using C++.
Device support
To get a smooth start with your product development, the IAR product installation comes with wide range of device-specific support.
generates is not always binary compatible between the cores. Therefore it is crucial to specify a processor option to the compiler. The default core is ARM7TDMI.
EXTENDED KEYWORDS
The compiler provides a set of keywords that can be used for configuring how the code is generated. For example, there are keywords for declaring special function types. By default, language extensions are enabled in the IDE.
The command line option -e makes the extended keywords available, and reserves them so that they cannot be used as variable names. See, -e, page 169 for additional information. For detailed descriptions of the extended keywords, see the chapter Extended keywords.
PRAGMA DIRECTIVES
The pragma directives control the behavior of the compiler, for example how it allocates memory, whether it allows extended keywords, and whether it issues warning messages. The pragma directives are always enabled in the compiler. They are consistent with ISO/ANSI C, and are very useful when you want to make sure that the source code is portable. For detailed descriptions of the pragma directives, see the chapter Pragma directives.
PREDEFINED SYMBOLS
With the predefined preprocessor symbols, you can inspect your compile-time environment, for example the CPU mode and time of compilation. For detailed descriptions of the predefined symbols, see the chapter The preprocessor.
EVENT HANDLING
In embedded systems, using interrupts is a method for handling external events immediately; for example, detecting that a button was pressed. In general, when an interrupt occurs in the code, the core simply stops executing the code it runs, and starts executing an interrupt routine instead. The compiler supports the following processor exception types: interrupts, software interrupts, and fast interrupts, which means that you can write your interrupt routines in C, see Interrupt functions, page 31.
SYSTEM STARTUP
In all embedded systems, system startup code is executed to initialize the systemboth the hardware and the software systembefore the main function of the application is called. The CPU imposes this by starting execution from a fixed memory address. As an embedded software developer, you must ensure that the startup code is located at the dedicated memory addresses, or can be accessed using a pointer from the vector table. This means that startup code and the initial vector table must be placed in non-volatile memory, such as ROM, EPROM, or flash. A C/C++ application further needs to initialize all global variables. This initialization is handled by the linker and the system startup code in conjunction. For more information, see Application executionan overview, page 14.
10
more deterministic and can reduce power consumption by using the CPU efficiently and putting the CPU in a lower-power state when idle. Using an RTOS can make your program easier to read and maintain, and in many cases smaller as well. Application code can be cleanly separated in tasks which are truly independent of each other. This makes teamwork easier, as the development work can be easily split into separate tasks which are handled by one developer or a group of developers. Finally, using an RTOS reduces the hardware dependence and creates a clean interface to the application, making it easier to port the program to different target hardware.
11
relocatable object files in the industry-standard format ELF, including the DWARF format for debug information. Note: The compiler can also be used for translating C/C++ source code into assembler source code. If required, you can modify the assembler source code which then can be assembled into object code. For more information about the IAR Assembler, see the ARM IAR Assembler Reference Guide. This illustration shows the translation process:
After the translation, you can choose to pack any number of modules into an archive, or in other words, a library. The important reason you should use libraries is that each module in a library is conditionally linked in the application, or in other words, is only included in the application if the module is used directly or indirectly by a module supplied as an object file. Optionally, you can create a library; then use the IAR utility iarchive.
12
The IAR ILINK Linker (ilinkarm.exe) is used for building the final application. Normally, ILINK requires the following information as input:
Several object files and possibly certain libraries A program start label (set by default) The linker configuration file that describes placement of code and data in the memory of the target system.
Note: The standard C/C++ library contains support routines for the compiler, and the implementation of the C/C++ standard library functions. During the linking, ILINK might produce error messages and logging messages on stdout and stderr. The log messages are useful for understanding why an application was linked the way it was, for example, why a module was included or a section removed. For an in-depth description of the procedure performed by ILINK, see The linking process, page 41.
13
AFTER LINKING
The IAR ILINK Linker produces an absolute object file in ELF format that contains the executable image. After linking, the produced absolute executable image can be used for:
Loading into the IAR C-SPY Debugger or any other external debugger that reads ELF and DWARF. Programming to a flash/PROM using a flash/PROM programmer. Before this is possible, the actual bytes in the image must be converted into the standard Motorola 32-bit S-record format or the Intel Hex-32 format. For this, use ielftool, see The IAR ELF Toolielftool, page 330.
This illustration shows the possible uses of the absolute output ELF/DWARF file:
14
Hardware initialization, which generally at least initializes the stack pointer. The hardware initialization is typically performed in the system startup code cstartup.s and if required, by an extra low-level routine that you provide. It might include resetting/starting the rest of the hardware, setting up the CPU, etc, in preparation for the software C/C++ system initialization.
Software C/C++ system initialization Typically, this includes assuring that every global (statically linked) C/C++ symbol receives its proper initialization value before the main function is called.
Application initialization This depends entirely on your application. Typically, it can include setting up an RTOS kernel and starting initial tasks for an RTOS-driven application. For a bare-bone application, it can include setting up various interrupts, initializing communication, initializing devices, etc.
For a ROM/flash-based system, constants and functions are already placed in ROM. All symbols placed in RAM must be initialized before the main function is called. The linker has already divided the available RAM into different areas for variables, stack, heap, etc.
15
The following sequence of illustrations gives a simplified overview of the different stages of the initialization.
1 When an application is started, the system startup code first performs hardware
initialization, such as initialization of the stack pointer to point at the end of the predefined stack area:
16
2 Then, memories that should be zero-initialized are cleared, in other words, filled with
zeros:
Typically, this is data referred to as zero-initialized data; variables declared as, for example, int i = 0;
17
3 For initialized data, data declared, for example, like int i = 6; the initializers are
copied from ROM to RAM:
18
For a detailed description about each stage, see System startup and termination, page 72. For more details about initialization of data, see Initialization at system startup, page 45.
On the command line, this line can be used for starting ILINK:
ilinkarm myfile.o myfile2.o -o a.out --config my_configfile.icf
In this example, myfile.o and myfile2.o are object files, and my_configfile.icf is the linker configuration file. The option -o specifies the name of the output file. Note: By default, the label where the application starts is __iar_program_start. You can use the --entry command line option to change this.
19
However, you must specify some additional options. This section gives an overview of the basic settings for the project setup that are needed to make the compiler and linker generate the best code for the ARM device you are using. You can specify the options either from the command line interface or in the IDE. You need settings for:
Processor configuration, that is processor variant, CPU mode, interworking, VFP and floating-point arithmetic, and byte order Optimization settings Runtime environment Customizing the ILINK configuration, see the chapter Linking your application AEBI compliance, see AEABI compliance, page 123.
In addition to these settings, many other options and settings can fine-tune the result even further. For details about how to set options and for a list of all available options, see the chapters Compiler options, Linker options, and the IAR Embedded Workbench IDE User Guide for ARM, respectively.
PROCESSOR CONFIGURATION
To make the compiler generate optimum code, you should configure it for the ARM core you are using.
Processor variant
The IAR C/C++ Compiler for ARM supports several different ARM cores and devices based on the instruction sets version 4, 5, 6, and 7. All supported cores support Thumb instructions and 64-bit multiply instructions. The object code that the compiler generates is not always binary compatible between the cores. Therefore it is crucial to specify a processor option to the compiler. The default core is ARM7TDMI. See the IAR Embedded Workbench IDE User Guide for ARM for information about setting the Processor variant option in the IDE. Use the --cpu option to specify the ARM core; see --cpu, page 162 for syntax information.
CPU mode
The IAR C/C++ Compiler for ARM supports two CPU modes: ARM and Thumb. All functions and function pointers will compile in the mode that you specify, except those explicitly declared __arm or __thumb. See the IAR Embedded Workbench IDE User Guide for ARM for information about setting the Processor variant or Chip option in the IDE.
20
Use the --arm or --thumb option to specify the CPU mode for your project; see --arm, page 162 and --thumb, page 187, for syntax information.
Interworking
When code is compiled with the --interwork option, ARM and Thumb code can be freely mixed. Interworking functions can be called from both ARM and Thumb code. Interworking is default for devices based on the instruction sets version 5, 6, and 7, or when using the --aeabi compiler option. See the IAR Embedded Workbench IDE User Guide for ARM for information about setting the Generate interwork code option in the IDE. Use the --interwork option to specify interworking capabilities for your project; see --interwork, page 173, for syntax information.
Byte order
The IAR C/EC++ Compiler for ARM supports the big-endian and little-endian byte order. All user and library modules in your application must use the same byte order. See the IAR Embedded Workbench IDE User Guide for ARM for information about setting the Endian mode option in the IDE. Use the --endian option to specify the byte order for your project; see --endian, page 170, for syntax information.
21
optimizations will make the application both smaller and faster. However, when this is not the case, the compiler uses the selected optimization goal to decide how to perform the optimization. The optimization level and goal can be specified for the entire application, for individual files, and for individual functions. In addition, some individual optimizations, such as function inlining, can be disabled. For details about compiler optimizations and for more information about efficient coding techniques, see the chapter Efficient coding for embedded applications.
RUNTIME ENVIRONMENT
To create the required runtime environment you should choose a runtime library and set library options. You might also need to override certain library modules with your own customized versions. The runtime library provided is the IAR DLIB Library, which supports ISO/ANSI C and C++. This library also supports floating-point numbers in IEEE 754 format and it can be configured to include different levels of support for locale, file descriptors, multibyte characters, etc. The runtime library you choose can be one of the prebuilt libraries, or a library that you customized and built yourself. The IDE provides a library project template that you can use for building your own library version. This gives you full control of the runtime environment. If your project only contains assembler source code, you do not need to choose a runtime library. Note: Some tailoring might be required, for example to meet hardware requirements. For detailed information about the runtime environment, see the chapter The DLIB runtime environment. The way you set up a runtime environment and locate all the related files differs depending on which build interface you are usingthe IDE or the command line.
22
Based on which library configuration you choose and your other project settings, the correct library file is used automatically. For the device-specific include files, a correct include path is set up.
Specifies the include path to device-specific I/O definition files. Specifies the library configuration file, either DLib_Config_Normal.h or DLib_Config_Full.h
Table 3: Command line options for specifying library and dependency files
Normally, it is not needed to specify a library file explicitly, as ILINK automatically uses the correct library file. For a list of all prebuilt library object files for the IAR DLIB Library, see Using a prebuilt library, page 64. Here you also get information about how the object files correspond to the dependent project options, and the corresponding configuration files. Make sure to use the object file that matches your other project options.
The formatters used by the functions printf, scanf, and their variants, see Choosing formatters for printf and scanf, page 67. The size of the stack and the heap, see Setting up the stack, page 52, and Setting up the heap, page 52, respectively.
23
24
Data storage
This chapter gives a brief introduction to the memory layout of the ARM core and the fundamental ways data can be stored in memory: on the stack, in static (global) memory, or in heap memory. Finally, detailed information about data storage on the stack and the heap is provided.
Introduction
An ARM core can address 4 Gbytes of continuous memory, ranging from 0x00000000 to 0xFFFFFFFF. Different types of physical memory can be placed in the memory range. A typical application will have both read-only memory (ROM) and read/write memory (RAM). In addition, some parts of the memory range contain processor control registers and peripheral units.
Auto variables. All variables that are local to a function, except those declared static, are stored on the stack. These variables can be used as long as the function executes. When the function returns to its caller, the memory space is no longer valid.
Global variables and local variables declared static. In this case, the memory is allocated once and for all. The word static in this context means that the amount of memory allocated for this kind of variables does not change while the application is running. The ARM core has one single address space and the compiler supports full memory addressing.
Dynamically allocated data. An application can allocate data on the heap, where the data remains valid until it is explicitly released back to the system by the application. This type of memory is useful when the number of objects is not known until the application executes. Note that there are potential risks connected with using dynamically allocated data in systems with a limited amount of memory, or systems that are expected to run for a long time. For more information, see Dynamic memory on the heap, page 27.
25
THE STACK
The stack can contain:
Local variables and parameters not stored in registers Temporary results of expressions The return value of a function (unless it is passed in registers) Processor state during interrupts Processor registers that should be restored before the function returns (callee-save registers).
The stack is a fixed block of memory, divided into two parts. The first part contains allocated memory used by the function that called the current function, and the function that called it, etc. The second part contains free memory that can be allocated. The borderline between the two areas is called the top of stack and is represented by the stack pointer, which is a dedicated processor register. Memory is allocated on the stack by moving the stack pointer. A function should never refer to the memory in the area of the stack that contains free memory. The reason is that if an interrupt occurs, the called interrupt function can allocate, modify, andof coursedeallocate memory on the stack.
Advantages
The main advantage of the stack is that functions in different parts of the program can use the same memory space to store their data. Unlike a heap, a stack will never become fragmented or suffer from memory leaks. It is possible for a function to call itselfa recursive functionand each invocation can store its own data on the stack.
Potential problems
The way the stack works makes it impossible to store data that is supposed to live after the function returns. The following function demonstrates a common programming
26
Data storage
mistake. It returns a pointer to the variable x, a variable that ceases to exist when the function returns.
int *MyFunction() { int x; /* Do something here. */ return &x; /* Incorrect */ }
Another problem is the risk of running out of stack. This will happen when one function calls another, which in turn calls a third, etc., and the sum of the stack usage of each function is larger than the size of the stack. The risk is higher if large data objects are stored on the stack, or when recursive functionsfunctions that call themselves either directly or indirectlyare used.
Potential problems
Applications that are using heap-allocated objects must be designed very carefully, because it is easy to end up in a situation where it is not possible to allocate objects on the heap. The heap can become exhausted if your application uses too much memory. It can also become full if memory that no longer is in use was not released. For each allocated memory block, a few bytes of data for administrative purposes is required. For applications that allocate a large number of small blocks, this administrative overhead can be substantial. There is also the matter of fragmentation; this means a heap where small sections of free memory is separated by memory used by allocated objects. It is not possible to allocate a new object if no piece of free memory is large enough for the object, even though the sum of the sizes of the free memory exceeds the size of the object.
27
Unfortunately, fragmentation tends to increase as memory is allocated and released. For this reason, applications that are designed to run for a long time should try to avoid using memory allocated on the heap.
28
Functions
This chapter contains information about functions. It gives a brief overview of function-related extensionsmechanisms for controlling functionsand describes some of these mechanisms in more detail.
Function-related extensions
In addition to the ISO/ANSI C standard, the compiler provides several extensions for writing functions in C. Using these, you can:
Generate code for the different CPU modes ARM and Thumb Make functions execute in RAM Use primitives for interrupts, concurrency, and OS-related programming Facilitate function optimization Access hardware features.
The compiler uses compiler options, extended keywords, pragma directives, and intrinsic functions to support this. For more information about optimizations, see Efficient coding for embedded applications, page 127. For information about the available intrinsic functions for accessing hardware operations, see the chapter Intrinsic functions.
29
Execution in RAM
In the chapter Assembler language interface, the generated code is studied in more detail in the description of calling C functions from assembler language and vice versa.
Execution in RAM
The __ramfunc keyword makes a function execute in RAM, or in other words places the function in a section that has read/write attributes. The function is copied from ROM to RAM at system startup just like any initialized variable, see System startup and termination, page 72. The keyword is specified before the return type:
__ramfunc void foo(void);
If a function declared __ramfunc tries to access ROM, the compiler will issue a warning. If the whole memory area used for code and constants is disabledfor example, when the whole flash memory is being erasedonly functions and data stored in RAM may be used. Interrupts must be disabled unless the interrupt vector and the interrupt service routines are also stored in RAM. String literals and other constants can be avoided by using initialized variables. For example, the following lines:
const int myc[] = { 10, 20 }; msg("Hello"); may be rewritten to: static int myc[] = { 10, 20 }; static char hello[] = "Hello"; msg(hello); // // // // // // // // myc initializer in DATA_C (ROM) String literal in DATA_C (ROM) Initialized by cstartup Initialized by cstartup hello stored in DATA_I (RAM)
For more details, see Initializing codecopying ROM to RAM, page 55.
The extended keywords __irq, __fiq, __swi, and __nested The intrinsic functions __enable_interrupt, __disable_interrupt, __get_interrupt_state, and __set_interrupt_state.
30
Functions
Note: ARM Cortex-M has a different interrupt mechanism than other ARM devices, and for these devices a different set of primitives is available. For more details, see Interrupts for ARM Cortex-M, page 36.
INTERRUPT FUNCTIONS
In embedded systems, using interrupts is a method for handling external events immediately; for example, detecting that a button was pressed. In general, when an interrupt occurs in the code, the core simply stops executing the code it runs, and starts executing an interrupt routine instead. It is extremely important that the environment of the interrupted function is restored after the interrupt is handled; this includes the values of processor registers and the processor status register. This makes it possible to continue the execution of the original code after the code that handled the interrupt was executed. The compiler supports interrupts, software interrupts, and fast interrupts. For each interrupt type, an interrupt routine can be written. All interrupt functions must be compiled in ARM mode; if you are using Thumb mode, use the __arm extended keyword or the #pragma type_attribute=__arm directive to override the default behavior. Each interrupt routine is associated with a vector address/instruction in the exception vector table, which is specified in the ARM cores documentation. The interrupt vector is the address in the exception vector table. For the ARM cores, the exception vector table starts at address 0x0. To define an interrupt function, the __irq or the __fiq keyword can be used. For example:
__irq __arm void IRQ_Handler(void) { /* Do something */ }
See the ARM cores documentation for more information about the interrupt vector table.
31
The predefined functions are defined as weak symbols. A weak symbol is only included by the linker as long as no duplicate symbol is found. If another symbol is defined with the same name, it will take precedence. Your application can therefore simply define its own exception function by just defining it using the correct name. These exception function names are defined in cstartup.s and referred to by the library exception vector code:
Undefined_Handler SWI_Handler Prefetch_Handler Abort_Handler IRQ_Handler FIQ_Handler
To implement your own exception handler, define a function using the appropriate exception function name from the list above. For example to add an interrupt function in C, it is sufficient to define an interrupt function named IRQ_Handler:
__irq __arm void IRQ_Handler() { }
An interrupt function must have C linkage, read more in Calling convention, page 97. If you use C++, an interrupt function could look, for example, like this:
extern "C" { __irq __arm void IRQ_Handler(void); } __irq __arm void IRQ_Handler() { }
To declare an interrupt function, use the __irq extended keyword or the #pragma type_attribute=__irq directive. For syntax information, see __irq, page 238, and type_attribute, page 257, respectively.
32
Functions
To declare a fast interrupt function, use the __fiq extended keyword or the #pragma type_attribute=__fiq directive. For syntax information, see __fiq, page 237, and type_attribute, page 257, respectively.
Note: An interrupt function (irq) and a fast interrupt function (fiq) must have a return type of void and cannot have any parameters. A software interrupt function (swi) may have parameters and return values. By default, only four registers, R0R3, can be used for parameters and only the registers R0R1 can be used for return values.
NESTED INTERRUPTS
Interrupts are automatically disabled by the ARM core prior to entering an interrupt handler. If an interrupt handler re-enables interrupts, calls functions, and another interrupt occurs, then the return address of the interrupted functionstored in LRis overwritten when the second IRQ is taken. In addition, the contents of SPSR will be destroyed when the second interrupt occurs. The __irq keyword itself does not save and restore LR and SPSR. To make an interrupt handler perform the necessary steps needed when handling nested interrupts, the keyword __nested must be used in addition to __irq. The function prologfunction entrance sequencethat the compiler generates for nested interrupt handlers will switch from IRQ mode to system mode. Make sure that both the IRQ stack and system stack is set up. If you use the default cstartup.s file, both stacks are correctly set up. Compiler-generated interrupt handlers that allow nested interrupts are supported for IRQ interrupts only. The FIQ interrupts are designed to be serviced quickly, which in most cases mean that the overhead of nested interrupts would be too high. This example shows how to use nested interrupts with the ARM vectored interrupt controller (VIC):
__irq __nested __arm void interrupt_handler(void) { void (*interrupt_task)(); unsigned int vector; vector = VICVectAddr; // Get interrupt vector. VICVectAddr = 0; // Acknowledge interrupt in VIC. interrupt_task = (void(*)())vector; __enable_interrupt(); // Allow other IRQ interrupts to be serviced from this point. // Execute the task associated with this interrupt.
(*interrupt_task)(); }
33
Note: The __nested keyword requires the processor mode to be in either User or System mode.
SOFTWARE INTERRUPTS
Software interrupt functions are slightly more complex than other interrupt functions, in the way that they need a software interrupt handler (a dispatcher), are invoked (called) from running application software, and that they accept arguments and have return values. The mechanisms for calling a software interrupt function and how the software interrupt handler dispatches the call to the actual software interrupt function is described here.
In this case, the assembler instruction SVC 0x23 will be generated where the function is called. Software interrupt functions follow the same calling convention regarding parameters and return values as an ordinary function, except for the stack usage, see Calling convention, page 97. For more information, see __swi, page 241, and swi_number, page 257, respectively.
34
Functions
INTERRUPT OPERATIONS
An interrupt function is called when an external event occurs. Normally it is called immediately while another function is executing. When the interrupt function has finished executing, it returns to the original function. It is imperative that the environment of the interrupted function is restored; this includes the value of processor registers and the processor status register. When an interrupt occurs, the following actions are performed:
The operating mode is changed corresponding to the particular exception The address of the instruction following the exception entry instruction is saved in R14 of the new mode The old value of the CPSR is saved in the SPSR of the new mode Interrupt requests are disabled by setting bit 7 of the CPSR and, if the exception is a fast interrupt, further fast interrupts are disabled by setting bit 6 of the CPSR The PC is forced to begin executing at the relevant vector address.
For example, if an interrupt for vector 0x18 occurs, the processor will start to execute code at address 0x18. The memory area that is used as start location for interrupts is called the interrupt vector table. The content of the interrupt vector is normally a branch instruction jumping to the interrupt routine. Note: If the interrupt function enables interrupts, the special processor registers needed to return from the interrupt routine must be assumed to be destroyed. For this reason they must be stored by the interrupt routine to be restored before it returns. This is handled automatically if the __nested keyword is used.
35
The vector table is implemented as an array. It should always have the name __vector_table, because cmain refers to that symbol and C-SPY looks for that symbol when determining where the vector table is located. The predefined exception functions are defined as weak symbols. A weak symbol is only included by the linker as long as no duplicate symbol is found. If another symbol is defined with the same name, it will take precedence. Your application can therefore simply define its own exception function by just defining it using the correct name from the list above. If you need other interrupts or other exception handlers, you must make a copy of the cstartup_M.c or cstartup_M.s file and make the proper addition to the vector table. The intrinsic functions __get_CPSR and __set_CPSR are not available when you compile for ARM Cortex-M. Instead, if you need to get or set values of these or other registers, you can use inline assembler. For more information, see Passing values between C and assembler objects, page 143.
36
Functions
called, it must be applied to an object. When an interrupt occurs and the interrupt function is called, there is no object available to apply the member function to. Special function types can be used for static member functions. For example, in the following example, the function handler is declared as an interrupt function:
class Device { static __irq void handler(); };
37
38
Linkingan overview
The IAR ILINK Linker is a powerful, flexible software tool for use in the development of embedded applications. It is equally well suited for linking small, single-file, absolute assembler programs as it is for linking large, relocatable, multi-module, C/C++, or mixed C/C++ and assembler programs. ILINK combines one or more relocatable object filesproduced by the IAR Systems compiler or assemblerwith selected parts of one or more object libraries to produce an executable image in the industry-standard format Executable and Linking Format (ELF). ILINK will automatically load only those library modulesuser libraries and standard C or C++ library variantsthat are actually needed by the application you are linking. Further, ILINK eliminates duplicate sections and sections that are not required. ILINK can link both ARM and Thumb code, as well as a combination of them. By automatically inserting additional instructions (veneers), ILINK will assure that the destination will be reached for any calls and branches, and that the processor state is switched when required. For more details about how to generate veneers, see Veneers, page 57. ILINK uses a configuration file where you can specify separate locations for code and data areas of your target system memory map. This file also supports automatic handling of the applications initialization phase, which means initializing global variable areas and code areas by copying initializers and possibly decompressing them as well. The final output produced by ILINK is an absolute object file containing the executable image in the ELF (including DWARF for debug information) format. The file can be downloaded to C-SPY or any other debugger that supports ELF/DWARF, or it can be programmed into EPROM. To handle ELF files, various tools are included. For a list of included utilities, see Specific ELF tools, page 4.
39
Several sections of code or data Runtime attributes specifying various types of information, for example the used device Optionally, debug information in DWARF format A symbol table of all global symbols and all external symbols used.
A section is a logical entity containing a piece of data or code that should be placed at a physical location in memory. A section can consist of several section fragments, typically one for each variable or function (symbols). A section can be placed either in RAM or in ROM. In a normal embedded application, sections that are placed in RAM do not have any content, they only occupy space. Each section has a name and a type attribute that determines the content. The type attribute is used (together with the name) for selecting sections for the ILINK configuration. The most commonly used attributes are:
code readonly readwrite zeroinit Executable code Constant variables Initialized variables Zero-initialized variables
Note: In addition to these section typessections that contain the code and data that are part of your applicationa final object file will contain many other types of sections, for example sections that contain debugging information or other type of meta information. A section is the smallest linkable unit; but if possible, ILINK can exclude smaller unitssection fragmentsfrom the final application. For more information, see Keeping modules, page 51, and Keeping symbols and sections, page 52. At compile time, data and functions are placed in different sections. At link time, one of the most important functions of the linker is to assign execute addresses to the various sections used by the application. The IAR build tools have many predefined section names. See the chapter Section reference for more details about each section.
40
Determine which modules to include in the application. Modules provided in object files are always included. A module in a library file is only included if it provides a definition for a global symbol that is referenced from an included module. Select which standard library files to use. The selection is based on attributes of the included modules. These libraries are then used for satisfying any still outstanding undefined symbols. Determine which sections/section fragments from the included modules to include in the application. Only those sections/section fragments that are actually needed by the application are included. There are several ways to determine of which sections/section fragments that are needed, for example, the __root object attribute, the #pragma required directive, and the keep linker directive. In case of duplicate sections, only one is included. Where appropriate, arrange for the initialization of initialized variables and code in RAM. The initialize directive causes the linker to create extra sections to enable copying from ROM to RAM. Each section that will be initialized by copying is divided into two sections, one for the ROM part and one for the RAM part. If manual initialization is not used, the linker also arranges for the startup code to perform the initialization. Determine where to place each section according to the section placement directives in the linker configuration file. Sections that are to be initialized by copying appear twice in the matching against placement directives, once for the ROM part and once for the RAM part, with different attributes. During the placement, the linker also adds any required veneers to make a code reference reach its destination or to switch CPU modes. Produce an absolute object file that contains the executable image and any debug information provided. This involves resolving symbolic references between sections, and locating relocatable values.
41
Optionally, produce a map file that lists the result of the section placement, the address of each global symbol, and finally, a summary of memory usage for each module and library.
During the linking, ILINK might produce error messages and logging messages on stdout and stderr. The log messages are useful for understanding why an application was linked as it was. For example, why a module or section (or section fragment) was included. Note: To see the actual content of an ELF object file, use ielfdumparm. See The IAR ELF Dumper for ARMielfdumparm, page 336.
42
Populated regions of those memories How to treat input sections Created sections How to place sections into the available regions.
The file consists of a sequence of declarative directives. This means that the linking process will be governed by all directives at the same time. To use the same source code with different derivatives, just rebuild the code with the appropriate configuration file.
This configuration file defines one addressable memory Mem with the maximum of 4 Gbytes of memory. Further, it defines a ROM region and a RAM region in Mem, namely ROM and RAM. Each region has the size of 64 Kbytes. The file then creates an empty block called STACK with a size of 4 Kbytes in which the application stack will reside. To create a block is the basic method which you can use to
43
get detailed control of placement, size, etc. It can be used for grouping sections, but also as in this example, to specify the size and placement of an area of memory. Next, the file defines how to handle the initialization of variables, read/write type (readwrite) sections. In this example, the initializers are placed in ROM and copied at startup of the application to the RAM area. By default, ILINK may compress the initializers if this appears to be advantageous. The last part of the configuration file handles the actual placement of all the sections into the available regions. First, the startup codedefined to reside in the read-only (readonly) section .cstartupis placed at the start of the ROM region, that is at address 0x10000. Note that the part within {} is referred to as section selection and it selects the sections for which the directive should be applied to. Then the rest of the read-only sections are placed in the ROM region. Note that the section selection { readonly section .cstartup } takes precedence over the more generic section selection { readonly }. Finally, the read/write (readwrite) sections and the STACK block are placed in the RAM region. This illustration gives a schematic overview of how the application is placed in memory:
44
In addition to these standard directives, a configuration file can contain directives that define how to:
Map a memory that can be addressed in multiple ways Handle conditional directives Create symbols with values that can be used in the application More in detail, select the sections a directive should be applied to More in detail, initialize code and data.
For more details and examples about customizing the linker configuration file, see the chapter Linking your application. For reference information about the linker configuration file, see the chapter The linker configuration file.
Source
Section type
Section content
Zero-initialized data Zero-initialized data Initialized data (non-zero) Non-initialized data Constants Code
int i; int i = 0; int i = 6; __no_init int i; const int i = 6; __ramfunc void myfunc() {}
Read/write data, zero-init Read/write data, zero-init Read/write data Read/write data, zero-init Read-only data Read/write code
Note: Clustering of static variables might group zero-initialized variables together with initialized data in .data.
45
For a summary of all supported sections, see the chapter Section reference.
Sections that should be zero-initialized are handled automatically by ILINK; they should only be placed in RAM Sections that should be initialized, except for zero-initialized sections, should be listed in an initialize directive Normally during linking, a section that should be initialized is split in two sections, where the original initialized section will keep the name. The contents are placed in the new initializer section, which will keep the original name suffixed with _init. The initializers should be placed in ROM and the initialized sections in RAM, by means of placement directives. The most common example is the .data section that the linker splits in .data and .data_init.
Sections that contains constants should not be initialized; they should only be placed in flash/ROM Sections holding __no_init declared variables should not be initialized and thus should be listed in a do not initialize directive. They should also be placed in RAM.
For detailed information and examples about how to configure the initialization, see Linking considerations, page 47.
46
Linking considerations
Before you can link your application, you must set up the configuration required by ILINK. Typically, you must consider:
Defining your own memory areas Placing sections Keeping modules in the application Keeping symbols and sections in the application Application startup Setting up the stack and heap Setting up the atexit limit Changing the default initialization Symbols for controlling the application Standard library handling Other output formats than ELF/DWARF Veneers.
generic.icf, designed for all cores except for Cortex-M cores generic_cortex.icf, designed for all Cortex-M cores
These files contain the information required by ILINK. The only change you will normally have to make to the supplied configuration file is to customize the start and end addresses of each region so they fit the target system memory map. If, for example, your application uses additional external RAM, you must also add details about the external RAM memory area.
47
Linking considerations
To edit a linker configuration file, use the editor in the IDE, or any other suitable editor. Alternatively, choose Project>Options>Linker and click the Edit button on the Config page to open the dedicated linker configuration file editor. Remember not to change the original template file. We recommend that you make a copy in the working directory, and modify the copy instead. If you are using the linker configuration file editor in the IDE, the IDE will make a copy for you. Each project in the IDE should have a reference to one, and only one, linker configuration file. This file can be edited, but for the majority of all projects it is sufficient to configure the vital parameters in Project>Options>Linker>Config.
Each region definition must be tailored for the actual hardware. To find out how much of each memory that was filled with code and data after linking, inspect the memory summary in the map file (command line option --map).
48
define region ROM2 = Mem:[from 0x80000 size 0x20000] | Mem:[from 0xC0000 size 0x08000];
or equivalently
define region ROM2 = Mem:[from 0x80000 to 0xC7FFF] Mem:[from 0xA0000 to 0xBFFFF];
Sharing memories
If your core can address a physical memory either by:
Several different addressing modes; addresses in different defined memories are actually the same physical entity Using different addresses in the same memory, for example some bits in the address are not connected to the physical memory
The sharing directive instructs ILINK to allocate contents in all connected memories if any content is placed in one memory.
PLACING SECTIONS
The default configuration file that you selected places all predefined sections in memory, but there are situations when you might want to modify this. For example, if you want
49
Linking considerations
to place the section that holds constant symbols in the CONSTANT region instead of in the default place. In this case, use the place in directive, for example:
/* Place place in /* Place place in sections with readonly content in the ROM region */ ROM {readonly}; the constant symbols in the CONSTANT region */ CONSTANT {readonly section .rodata};
Note: Placing a sectionused by the IAR build toolsin a different memory which use a different way of referring to its content, will fail. For the result of each placement directive after linking, inspect the placement summary in the map file (the command line option --map).
name
createSection
/* Create a section */ section myOwnSection:CONST /* And fill it with constant bytes */ dcb 5, 6, 7, 8 end
50
To place your new section, the original place in ROM {readonly}; directive is sufficient. However, to place the section MyOwnSection explicitly, update the linker configuration file with a place in directive, for example:
/* Place MyOwnSection in the ROM region */ place in ROM {readonly section MyOwnSection};
To retrieve the start of the allocated memory from the application, the source code could look like this:
/* Declares a section */ #pragma section = "TempStorage" char *TempStorage() { /* Return start address of section TempStorage. */ return __section_begin("TempStorage"); }
KEEPING MODULES
If a module is linked as an object file, it is always kept. That is, it will contribute to the linked application. However, if a module is part of a library, it is included only if it is symbolically referred to from other parts of the application. This is true, even if the library module contains a root symbol. To assure that such a library module is always included, use iarchive to extract the module from the library, see The IAR Archive Tooliarchive, page 323. For information about included and excluded modules, inspect the log file (the command line option --log modules). For more information about modules, see Modules and sections, page 40.
51
Linking considerations
APPLICATION STARTUP
By default, the point where the application starts execution is defined by the __iar_program_start label, which is defined to point at the start of the cstartup.s file. The label is also communicated via ELF to any debugger that is used. To change the start point of the application to another label, use the ILINK option --entry; see --entry, page 196.
Specify an appropriate size for your application. To read more about the stack, see Stack considerations, page 115.
52
Choosing the packing algorithm Overriding the default copy-initialize function Manual initialization Initializing codecopying ROM to RAM.
For information about the performed initializations, inspect the log file (the command line option --log initialization).
To read more about the available packing algorithms, see Initialize directive, page 305.
53
Linking considerations
Manual initialization
The initialize manually directive lets you take complete control over initialization. For each involved section, ILINK creates an extra section that contains the initialization data, but makes no arrangements for the actual copying. This directive is, for example, useful for overlays:
/* Sections MYOVERLAY1 and MYOVERLAY2 will be overlaid in MyOverlay */ define overlay MyOverlay { section MYOVERLAY1 }; define overlay MyOverlay { section MYOVERLAY2 }; /* Split the overlay sections but without initialization during system startup */ initialize manually { section MYOVERLAY* }; /* Place the initializer sections in a block each */ define block MyOverlay1InRom { section MYOVERLAY1_init }; define block MyOverlay2InRom { section MYOVERLAY2_init }; /* Place the overlay and the initializers for it */ place in RAM { overlay MyOverlay }; place in ROM { block MyOverlay1InRom, block MyOverlay2InRom };
The application can then start a specific overlay by copying, as in this case, ROM to RAM:
#include <string.h>
54
/* Function that switches in image 1 into the overlay. */ void SwitchToOverlay1() { char *targetAddr = __section_begin("MyOverlay"); char *sourceAddr = __section_begin("MyOverlay1InRom"); char *sourceAddrEnd = __section_end("MyOverlay1InRom"); int size = sourceAddrEnd - sourceAddr; memcpy(targetAddr, sourceAddrEnd, size); }
The block definitions makes it possible to refer to the start and end of the blocks from the application. For more examples, see Interaction between the tools and your application, page 117.
55
Linking considerations
The readwrite pattern will match all statically initialized variables and arrange for them to be initialized at startup. The readonly pattern will do the same for all read-only code and data, except for code and data needed for the initialization. To reduce the ROM space that is needed, it might be useful to compress the data with one of the available packing algorithms. For example,
initialize by copy { readonly, readwrite } with packing lzw
To read more about the available compression algorithms, see Initialize directive, page 305. Because the function __low_level_init, if present, is called before initialization, it, and anything it needs, will not be copied from ROM to RAM either. In some circumstancesfor example, if the ROM contents are no longer available to the program after startupyou might need to avoid using the same functions during startup and in the rest of the code. If anything else should not be copied, include it in an except clause. This can apply to, for example, the interrupt vector table. It is also recommended to exclude the C++ dynamic initialization table from being copied to RAM, as it is typically only read once and then never referenced again. For example, like this:
initialize by copy { readonly, readwrite } except { section .intvec, /* Dont copy interrupt table */ section .init_array } /* Dont copy C++ init table */
56
For information about the addresses and sizes of all global (statically linked) symbols, inspect the entry list in the map file (the command line option --map). For more information, see Interaction between the tools and your application, page 117.
VENEERS
The ARM cores need to use veneers on two occasions:
When calling an ARM function from Thumb mode or vice versa; the veneer then changes the state of the microprocessor. If the core supports the BLX instruction, a veneer is not needed for changing modes. When calling a function that it cannot normally reach; the veneer introduces code which makes the call successfully reach the destination.
Code for veneers can be inserted between any caller and called function. As a result, the R12 register must be treated as a scratch register at function calls, including functions written in assembler. This also applies to jumps. For more information, see --no_veneers, page 202.
Messages at link time, for examples when a relocation error occurs The --log option that makes ILINK log information to stdout, which can be useful to understand why an executable image became the way it is, see --log, page 199
57
The --map option that makes ILINK produce a memory map file, which contains the result of the linker configuration file, see --map, page 200.
RELOCATION ERRORS
For each instruction that cannot be relocated correctly, ILINK will generate a relocation error. This can occur for instructions where the target is out of reach or is of an incompatible type, or for many other reasons. A relocation error produced by ILINK can look like this:
Error[Lp002]: relocation failed: out of range or illegal value Kind : R_XXX_YYY[0x1] Location : 0x40000448 "myfunc" + 0x2c Module: somecode.o Section: 7 (.text) Offset: 0x2c Destination: 0x9000000c "read" Module: read.o(iolib.a) Section: 6 (.text) Offset: 0x0
Kind Location
The relocation directive that failed. The directive depends on the instruction used. The location where the problem occurred, described with the following details: The instruction address, expressed both as a hexadecimal value and as a label with an offset. In this example, 0x40000448 and "myfunc" + 0x2c. The module, and the file. In this example, the module somecode.o. The section number and section name. In this example, section number 7 with the name .text. The offset, specified in number of bytes, in the section. In this example, 0x2c.
58
Message entry
Description
Destination
The target of the instruction, described with the following details: The instruction address, expressed both as a hexadecimal value and as a label with an offset. In this example, 0x9000000c and "read" (thus, no offset). The module, and when applicable the library. In this example, the module read.o and the library iolib.a. The section number and section name. In this example, section number 6 with the name .text. The offset, specified in number of bytes, in the section. In this example, 0x0.
Possible solutions
In this case, the distance from the instruction in getchar to __read is too long for the branch instruction. Possible solutions include ensuring that the two .text sections are allocated closer to each other or using some other calling mechanism that can reach the required distance. It is also possible that the referring function tried to refer to the wrong target and that this caused the range error. Different range errors have different solutions. Usually, the solution is a variant of the ones presented above, in other words modifying either the code or the section placement.
59
60
For information about AEABI compliance, see AEABI compliance, page 123.
61
The runtime library is delivered both as prebuilt libraries and (depending on your product package) as source files, and you can find them in the product subdirectories arm\lib and arm\src\lib, respectively. The runtime environment also consists of a part with specific support for the target system, which includes:
Direct access to low-level processor operations by means of intrinsic functions, such as functions for register handling Peripheral unit registers and interrupt definitions in include files The Vector Floating Point (VFP) coprocessor.
Runtime environment support, that is, startup and exit code and low-level interface to some library functions. Special compiler support for some functions, for instance functions for floating-point arithmetics.
The runtime environment support and the size of the heap must be tailored for the specific hardware and application requirements. For further information about the library, see the chapter Library functions.
LIBRARY SELECTION
To configure the most code-efficient runtime environment, you must determine your application and hardware requirements. The more functionality you need, the larger your code will become. IAR Embedded Workbench comes with a set of prebuilt runtime libraries. To get the required runtime environment, you can customize it by:
Setting library options, for example, for choosing scanf input and printf output formatters, and for specifying the size of the stack and the heap Overriding certain library functions, for example cstartup.s, with your own customized versions Choosing the level of support for certain standard library functionality, for example, locale, file descriptors, and multibyte characters, by choosing a library configuration: normal or full.
You can also make your own library configuration, but that requires that you rebuild the library. This allows you to get full control of the runtime environment. Note: Your application project must be able to locate the library, include files, and the library configuration file. ILINK will automatically choose a prebuilt library suitable for the application.
62
There is no prebuilt library for the required combination of compiler options or hardware support You want to define your own library configuration with support for locale, file descriptors, multibyte characters, et cetera.
For information about how to build a customized library, see Building and using a customized library, page 71.
LIBRARY CONFIGURATIONS
It is possible to configure the level of support for, for example, locale, file descriptors, multibyte characters. The runtime library configuration is defined in the library configuration file. It contains information about what functionality is part of the runtime environment. The configuration file is used for tailoring a build of a runtime library, and tailoring the system header files used when compiling your application. The less functionality you need in the runtime environment, the smaller it is. These DLIB library configurations are available:
Library configuration Description
Normal DLIB
No locale interface, C locale, no file descriptor support, no multibyte characters in printf and scanf, and no hexadecimal floating-point numbers in strtod. Full locale interface, C locale, file descriptor support, multibyte characters in printf and scanf, and hexadecimal floating-point numbers in strtod.
Full DLIB
You can also define your own configurations, which means that you must modify the configuration file. Note that the library configuration file describes how a library was built and thus cannot be changed unless you rebuild the library. For further information, see Building and using a customized library, page 71. The prebuilt libraries are based on the default configurations, see Using a prebuilt library, page 64. There is also a ready-made library project template that you can use if you want to rebuild the runtime library.
63
In the IDE, the linker will include the correct library object file and library configuration file based on the options you select. See the IAR Embedded Workbench IDE User Guide for ARM for additional information. If you build your application from the command line, you must specify the library configuration file for the compiler, either DLib_Config_Full.h or DLib_Config_Normal.h, for example:
--dlib_config C:\...\DLib_Config_Normal.h
You can find the library object files and the library configuration files in the subdirectory arm\lib\, and the library configuration files in the arm\inc directory.
64
C/C++ standard library functions These are the functions defined by the ISO/ANSI C/C++ standard, for example functions like printf and scanf.
Runtime support functions These are functions for system startup, initialization, floating-point arithmetics, ABI support, and some of the functions part of the ISO/ANSI C/C++ standard.
Debug support functions These are functions for debug support for the semihosting interface.
<architecture> is the name of the architecture. It can be one of 4t, 5E, 6M, or 7M
for the ARM architectures v4T, v5TE, v6M, or v7M, respectively. Libraries built for the v5TE architecture are also used for the v6 architecture.
<cpu_mode> is one of t or a, for Thumb and ARM, respectively. <endian> is one of l or b, for little-endian and big-endian, respectively. <fp_implementation> is _ when the library is compiled without VFP support, that is, software implementation compliant to AAPCS. It is s when the library is compiled with VFP support and compliant to AAPCS/STD. It is v when compiled with VFP support and using VFP registers in function calls; this is not AEABI compliant. The supported version of VFP is v1 when architecture is 4t and v2 when architecture is 5E. <interworking> is i when the library contains interworking code, otherwise it is _. <library_config> is one of n or f for normal and full, respectively. <debug_interface> is one of s, b or i, for the SWI/SVC mechanism, the BKPT
mechanism, and the IAR-specific breakpoint mechanism, respectively. For more information, see --semihosting, page 205.
65
Formatters used by printf and scanf The sizes of the heap and the stack
Formatters for printf and scanf Startup and termination code Low-level input and output File input and output Low-level environment functions Low-level signal functions Low-level time functions
Table 7: Customizable items
Choosing formatters for printf and scanf, page 67 System startup and termination, page 72 Standard streams for input and output, page 77 File input and output, page 80 Environment interaction, page 83 Signal and raise, page 84 Time, page 85
66
Described in
Stack considerations, page 115 Heap considerations, page 117 Placing code and datathe linker configuration file, page 42
For a description about how to override library modules, see Overriding library modules, page 69.
67
Yes
Yes
Yes No No No No No No No No
Yes
Floating-point specifiers e, E, f, F, g, Yes and G Conversion specifier n Format flag space, +, -, #, and 0 Yes Yes
Length modifiers h, l, L, s, t, and Z Yes Field width and precision, including * Yes long long support
Table 8: Formatters for printf
Yes
For information about how to fine-tune the formatting capabilities even further, see Configuration symbols for printf and scanf, page 79.
68
Yes
Yes
Yes
Yes
No No No Yes Yes No
No No No No No No
Floating-point specifiers e, E, f, F, g, Yes and G Conversion specifier n Scan set [ and ] Assignment suppressing * long long support
Table 9: Formatters for scanf
For information about how to fine-tune the formatting capabilities even further, see Configuration symbols for printf and scanf, page 79.
69
Note: If you override a default I/O library module with your own module, C-SPY support for the module is turned off. For example, if you replace the module __write with your own version, the C-SPY Terminal I/O window will not be supported.
1 Copy the appropriate library_module.c file to your project directory. 2 Make the required additions to the file (or create your own routine, using the default
file as a model).
3 Add the customized file to your project. 4 Rebuild your project. Overriding library modules from the command line
This procedure is applicable to any source file in the library, which means that library_module.c in this example can be any module in the library.
1 Copy the appropriate library_module.c to your project directory. 2 Make the required additions to the file (or create your own routine, using the default
file as a model), and make sure that it has the same module name as the original module. The easiest way to achieve this is to save the new file under the same name as the original file.
3 Compile the modified file using the same options as for the rest of the project:
iccarm library_module.c
Make sure that library_module.o is placed before the library on the command line. This ensures that your module is used instead of the one in the library. Run ILINK to rebuild your application. This will use your version of library_module.o, instead of the one in the library. For information about the ILINK options, see the chapter Linker options.
70
Set up a library project Make the required library modifications Build your customized library Finally, make sure your application project will use the customized library.
Note: To build IAR Embedded Workbench projects from the command line, use the IAR Command Line Build Utility (iarbuild.exe). However, no make or batch files for building the library from the command line are provided. For information about the build process and the IAR Command Line Build Utility, see the IAR Embedded Workbench IDE User Guide for ARM.
71
1 Choose Project>Options and click the Library Configuration tab in the General
Options category.
2 Choose Custom DLIB from the Library drop-down menu. 3 In the Configuration file text box, locate your library configuration file. 4 Click the Library tab, also in the Linker category. Use the Additional libraries text
box to locate your library file.
For information about how to customize the system startup code, see Customizing system initialization, page 76.
SYSTEM STARTUP
During system startup, an initialization sequence is executed before the main function is entered. This sequence performs initializations required for the target hardware and the C/C++ environment.
72
When the CPU is reset it will jump to the program entry label __iar_program_start in the system startup code. Exception stack pointers are initialized to the end of each corresponding section The stack pointer is initialized to the end of the CSTACK block The function __low_level_init is called if you defined it, giving the application a chance to perform early initializations.
Note: For Cortex-M devices, the second bullet in the above list is not valid. The first and the third bullets are handled slightly differently. At reset, a Cortex-M CPU initializes PC and SP from the vector table (__vector_table), which is defined in the cstartup_M.c file.
73
Static and global variables are initialized. That is, zero-initialized variables are cleared and the values of other initialized variables are copied from ROM to RAM memory. This step is skipped if __low_level_init returns zero. For more details, see Initialization at system startup, page 45 Static C++ objects are constructed The main function is called, which starts the application.
For an overview of the initialization phase, see Application executionan overview, page 14.
74
SYSTEM TERMINATION
This illustration shows the different ways an embedded application can terminate in a controlled way:
As the ISO/ANSI C standard states that the two methods should be equivalent, the system startup code calls the exit function if main returns. The parameter passed to the exit function is the return value of main. The default exit function is written in C. It calls a small assembler function _exit that will perform these operations:
Call functions registered to be executed when the application ends. This includes C++ destructors for static and global variables, and functions registered with the standard C function atexit Close all open files Call __exit When __exit is reached, stop the system.
An application can also exit by calling the abort or the _Exit function. The abort function just calls __exit to halt the system, and does not perform any type of cleanup. The _Exit function is equivalent to the abort function, except for the fact that _Exit takes an argument for passing exit status information.
75
If you want your application to do anything extra at exit, for example resetting the system, you can write your own implementation of the __exit(int) function.
__LOW_LEVEL_INIT
Two skeleton low-level initialization files are supplied with the product: a C source file, low_level_init.c and an alternative assembler source file, low_level_init.s. The latter is part of the prebuilt runtime environment. The only limitation using the C source version is that static initialized variables cannot be used within the file, as variable initialization has not been performed at this point. The value returned by __low_level_init determines whether or not data sections should be initialized by the system startup code. If the function returns 0, the data sections will not be initialized.
76
--entry, page 196. For Cortex-M, you must create a modified copy of cstartup_M.s or cstartup_M.c to use interrupts or other exception handlers.
77
size_t __write(int handle, const unsigned char *buf, size_t bufSize) { size_t nChars = 0; /* Check for the command to flush all handles */ if (handle == -1) { return 0; } /* Check for stdout and stderr (only necessary if FILE descriptors are enabled.) */ if (handle != 1 && handle != 2) { return -1; } for (/* Empty */; bufSize > 0; --bufSize) { lcdIO = *buf; ++buf; ++nChars; } return nChars; }
Note: A call to __write where buf has the value NULL is a command to flush the handle. When the handle is -1, all streams should be flushed.
78
(only necessary if FILE descriptors are enabled) */ if (handle != 0) { return -1; } for (/*Empty*/; bufSize > 0; --bufSize) { unsigned char c = kbIO; if (c == 0) break; *buf++ = c; ++nChars; } return nChars; }
For information about the @ operator, see Controlling data and function placement in memory, page 131.
Multibyte characters Long long (ll qualifier) Floating-point numbers Hexadecimal floating-point numbers Output count (%n)
79
Qualifiers h, l, L, v, t, and z Flags -, +, #, and 0 Width and precision Output char by char or buffered
When you build a library, these configurations determine what capabilities the function scanf should have:
Scanf configuration symbols Includes support for
Multibyte characters Long long (ll qualifier) Floating-point numbers Output count (%n) Qualifiers h, j, l, t, z, and L Scanset ([*]) Width
80
Template code for these I/O files are included in the product:
I/O function File Description
Closes a file. Sets the file position indicator. Opens a file. Reads a character buffer. Writes a character buffer. Removes a file. Renames a file.
The primitive functions identify I/O streams, such as an open file, with a file descriptor that is a unique integer. The I/O streams normally associated with stdin, stdout, and stderr have the file descriptors 0, 1, and 2, respectively. Note: If you link your library with I/O debugging support, C-SPY variants of the low-level I/O functions are linked for interaction with C-SPY. For more information, see Low-level interface for debug support, page 64.
Locale
Locale is a part of the C language that allows language- and country-specific settings for several areas, such as currency symbols, date and time, and multibyte character encoding. Depending on what runtime library you are using you get different level of locale support. However, the more locale support, the larger your code will get. It is therefore necessary to consider what level of support your application needs. The DLIB library can be used in two main modes:
With locale interface, which makes it possible to switch between different locales during runtime Without locale interface, where one selected locale is hardwired into the application.
81
Locale
All libraries with full library configuration have support for the locale interface. For prebuilt libraries with locale interface, it is by default only supported to switch multibyte character encoding during runtime. Libraries with normal library configuration do not have support for the locale interface.
If your application requires a different locale support, you must rebuild the library.
The standard C locale The POSIX locale A wide range of European locales.
See DLib_Defaults.h for a list of supported locale and encoding settings. If you want to customize the locale support, you simply define the locale configuration symbols required by your application. For more information, see Building and using a customized library, page 71. Note: If you use multibyte characters in your C or assembler source code, make sure that you select the correct locale symbol (the local host locale).
82
or
lang_REGION.encoding
The lang part specifies the language code, and the REGION part specifies a region qualifier, and encoding specifies the multibyte character encoding that should be used. The lang_REGION part matches the _LOCALE_USE_LANG_REGION preprocessor symbols that can be specified in the library configuration file.
Example
This example sets the locale configuration symbols to Swedish to be used in Finland and UTF8 multibyte character encoding:
setlocale (LC_ALL, "sv_FI.Utf8");
Environment interaction
According to the C standard, your application can interact with the environment using the functions getenv and system. Note: The putenv function is not required by the standard, and the library does not provide an implementation of it.
83
End the string with an extra null character (if you use a C string, this is added automatically). Assign the created sequence of strings to the __environ variable. For example:
const char MyEnv[] = Key=Value\0Key2=Value2\0; __environ = MyEnv;
If you need a more sophisticated environment variable handling, you should implement your own getenv, and possibly putenv function. This does not require that you rebuild the library. You can find source templates in the files getenv.c and environ.c in the arm\src\lib directory. For information about overriding default library modules, see Overriding library modules, page 69.
84
If you decide to rebuild the library, you can find source templates in the library project template. For further information, see Building and using a customized library, page 71.
Time
To make the time and date functions work, you must implement the three functions clock, time, and __getzone. This does not require that you rebuild the library. You can find source templates in the files clock.c and time.c, and getzone.c in the arm\src\lib directory. For information about overriding default library modules, see Overriding library modules, page 69. If you decide to rebuild the library, you can find source templates in the library project template. For further information, see Building and using a customized library, page 71. The default implementation of __getzone specifies UTC as the time zone. Note: If you link your application with support for I/O debugging, the functions clock and time are replaced by C-SPY variants that return the host clock and time respectively. For further information, see C-SPY runtime interface, page 86.
Strtod
The function strtod does not accept hexadecimal floating-point strings in libraries with the normal library configuration. To make a library do so, you must rebuild the library, see Building and using a customized library, page 71. Enable the configuration symbol _DLIB_STRTOD_HEX_FLOAT in the library configuration file.
Assert
If you linked your application with support for runtime debugging, an assert will print a message on stdout. If this is not the behavior you require, you must add the source file xreportassert.c to your application project. The __ReportAssert function generates the assert notification. You can find template code in the arm\src\lib directory. For further information, see Building and using a customized library, page 71. To turn off assertions, you must define the symbol NDEBUG. In the IDE, this symbol NDEBUG is by default defined in a Release project and not defined in a Debug project. If you build from the command line, you must explicitly define the symbol according to your needs. See NDEBUG, page 287.
85
Atexit
Atexit
The linker allocates a static memory area for atexit function calls. By default, the number of calls to the atexit function are limited to 32 bytes. To change this limit, see Setting up the atexit limit, page 53.
abort clock __close __exit __open __read remove rename _ReportAssert __seek system time __write
C-SPY notifies that the application has called abort Returns the clock on the host computer Closes the associated host file on the host computer C-SPY notifies that the end of the application was reached Opens a file on the host computer stdin, stdout, and stderr will be directed to the Terminal I/O window; all other files will read the associated host file Writes a message to the Debug Log window and returns -1 Writes a message to the Debug Log window and returns -1 Handles failed asserts Seeks in the associated host file on the host computer Writes a message to the Debug Log window and returns -1 Returns the time on the host computer stdin, stdout, and stderr will be directed to the Terminal I/O window, all other files will write to the associated host file
Table 13: Functions with special meanings when linked with debug info
86
These capabilities can be valuable during the early development of an application, for example in an application using file I/O before any flash file system I/O drivers are implemented. Or, if you need to debug constructions in your application that use stdin and stdout without the actual hardware device for input and output being available. Another debugging purpose can be to produce debug trace printouts.
87
The tools provided by IAR Systems use a set of predefined runtime model attributes to automatically ensure module consistency.
In this case, file1 cannot be linked with any of the other files, since the runtime attribute color does not match. Also, file4 and file5 cannot be linked together, because the taste runtime attribute does not match. On the other hand, file2 and file3 can be linked with each other, and with either file4 or file5, but not with both.
88
You can also use the rtmodel assembler directive to specify runtime model attributes in your assembler source code. For example:
rtmodel "color", "red"
For detailed syntax information, see the ARM IAR Assembler Reference Guide. At link time, the IAR ILINK Linker checks module consistency by ensuring that modules with conflicting runtime attributes will not be used together. If conflicts are detected, an error is issued.
89
90
Modules written entirely in assembler Intrinsic functions (the C alternative) Inline assembler.
It might be tempting to use simple inline assembler. However, you should carefully choose which method to use.
INTRINSIC FUNCTIONS
The compiler provides a few predefined functions that allow direct access to low-level processor operations without having to use the assembler language. These functions are known as intrinsic functions. They can be very useful in, for example, time-critical routines.
91
An intrinsic function looks like a normal function call, but it is really a built-in function that the compiler recognizes. The intrinsic functions compile into inline code, either as a single instruction, or as a short sequence of instructions. The advantage of an intrinsic function compared to using inline assembler is that the compiler has all necessary information to interface the sequence properly with register allocation and variables. The compiler also knows how to optimize functions with such sequences; something the compiler is unable to do with inline assembler sequences. The result is that you get the desired sequence properly integrated in your code, and that the compiler can optimize the result. For detailed information about the available intrinsic functions, see the chapter Intrinsic functions.
The function call mechanism is well-defined The code will be easy to read The optimizer can work with the C or C++ functions.
This causes some overhead in the form of a function call and return instruction sequences, and the compiler will regard some registers as scratch registers. However, the compiler will also assume that all scratch registers are destroyed by an inline assembler instruction. In many cases, the overhead of the extra instructions can be removed by the optimizer. An important advantage is that you will have a well-defined interface between what the compiler produces and what you write in assembler. When using inline assembler, you will not have any guarantees that your inline assembler lines do not interfere with the compiler generated code. When an application is written partly in assembler language and partly in C or C++, you are faced with several questions:
How should the assembler code be written so that it can be called from C? Where does the assembler code find its parameters, and how is the return value passed back to the caller? How should assembler code call functions written in C? How are global C variables accessed from code written in assembler language? Why does not the debugger display the call stack when assembler code is being debugged?
92
The first issue is discussed in the section Calling assembler routines from C, page 94. The following two are covered in the section Calling convention, page 97. The section Inline assembler, page 93, covers how to use inline assembler, but it also shows how data in memory is accessed. The answer to the final question is that the call stack can be displayed when you run assembler code in the debugger. However, the debugger requires information about the call frame, which must be supplied as annotations in the assembler source file. For more information, see Call frame information, page 103. The recommended method for mixing C or C++ and assembler modules is described in Calling assembler routines from C, page 94, and Calling assembler routines from C++, page 96, respectively.
INLINE ASSEMBLER
It is possible to insert assembler code directly into a C or C++ function. The asm keyword inserts the supplied assembler statement in-line, see Inline assembler, page 225 for reference information. The following example demonstrates the use of the asm keyword. This example also shows the risks of using inline assembler.
bool flag; void foo() { while (!flag) { asm(" ldr r2,[pc,#0] " b .+8 " DCD flag " ldr r3,[pc,#0] " b .+8 " DCD PIND " ldr r0,[r3] " str r0,[r2]"); } }
/* /* /* /* /* /* /* /*
r2 = address of flag jump over constant address of flag r3 = address of PIND jump over constant address of PIND r0 = PIND flag = r0
*/ */ */ */ */ */ */ */
In this example, the assignment of flag is not noticed by the compiler, which means the surrounding code cannot be expected to rely on the inline assembler statement. The inline assembler instruction will simply be inserted at the given location in the program flow. The consequences or side-effects the insertion might have on the surrounding code are not taken into consideration. If, for example, registers or memory locations are altered, they might have to be restored within the sequence of inline assembler instructions for the rest of the code to work properly.
93
Inline assembler sequences have no well-defined interface with the surrounding code generated from your C or C++ code. This makes the inline assembler code fragile, and will possibly also become a maintenance problem if you upgrade the compiler in the future. There are also several limitations to using inline assembler:
The compilers various optimizations will disregard any effects of the inline sequences, which will not be optimized at all In general, assembler directives will cause errors or have no meaning. Data definition directives will however work as expected Alignment cannot be controlled; this means, for example, that DC32 directives might be misaligned Auto variables cannot be accessed Alternative register names, mnemonics, and operators are not supported; read more about the -j assembler option in the ARM IAR Assembler Reference Guide.
Inline assembler is therefore often best avoided. If no suitable intrinsic function is available, we recommend that you use modules written in assembler language instead of inline assembler, because the function call to an assembler routine normally causes less performance reduction.
Conform to the calling convention Have a PUBLIC entry-point label Be declared as external before any call, to allow type checking and optional promotion of parameters, as in these examples:
extern int foo(void);
or
extern int foo(int i, int j);
One way of fulfilling these requirements is to create skeleton code in C, compile it, and study the assembler list file.
94
variables required and perform simple accesses to them. In this example, the assembler routine takes an int and a char, and then returns an int:
extern int gInt; extern char gChar; int Func(int arg1, char arg2) { int locInt = arg1; gInt = arg1; gChar = arg2; return locInt; } int main() { int locInt = gInt; gInt = Func(locInt, gChar); return 0; }
Note: In this example we use a low optimization level when compiling the code to show local and global variable access. If a higher level of optimization is used, the required references to local variables could be removed during the optimization. The actual function declaration is not changed by the optimization level.
The -lA option creates an assembler language output file including C or C++ source lines as assembler comments. The . (period) specifies that the assembler file should be named in the same way as the C or C++ module (skeleton), but with the filename extension s. Also remember to specify a low level of optimization, and -e for enabling language extensions. The result is the assembler source output file skeleton.s. Note: The -lA option creates a list file containing call frame information (CFI) directives, which can be useful if you intend to study these directives and how they are
95
used. If you only want to study the calling convention, you can exclude the CFI directives from the list file. In the IDE, choose Project>Options>C/C++ Compiler>List and deselect the suboption Include call frame information. On the command line, use the option -lB instead of -lA. Note that CFI information must be included in the source code to make the C-SPY Call Stack window work.
The calling convention The return values The global variables The function parameters How to create space on the stack (auto variables) Call frame information (CFI).
The CFI directives describe the call frame information needed by the Call Stack window in the debugger. For more information, see Call frame information, page 103.
96
The following example shows how to achieve the equivalent to a non-static member function, which means that the implicit this pointer must be made explicit. It is also possible to wrap the call to the assembler routine in a member function. Use an inline member function to remove the overhead of the extra callthis assumes that function inlining is enabled:
class MyClass; extern "C" { void DoIt(MyClass *ptr, int arg); } class MyClass { public: inline void DoIt(int arg) { ::DoIt(this, arg); } };
Calling convention
A calling convention is the way a function in a program calls another function. The compiler handles this automatically, but, if a function is written in assembler language, you must know where and how its parameters can be found, how to return to the program location from where it was called, and how to return the resulting value. It is also important to know which registers an assembler-level routine must preserve. If the program preserves too many registers, the program might be ineffective. If it preserves too few registers, the result would be an incorrect program. This section describes the calling conventions used by the compiler. These items are examined:
Choosing a calling convention Function declarations C and C++ linkage Preserved versus scratch registers Function entrance Function exit Return address handling.
97
Calling convention
At the end of the section, some examples are shown to describe the calling convention in practice. Unless otherwise noted, the calling convention used by the compiler adheres to AAPCS, a part of AEABI; see AEABI compliance, page 123.
FUNCTION DECLARATIONS
In C, a function must be declared in order for the compiler to know how to call it. A declaration could look as follows:
int MyFunction(int first, char * second);
This means that the function takes two parameters: an integer and a pointer to a character. The function returns a value, an integer. In the general case, this is the only knowledge that the compiler has about a function. Therefore, it must be able to deduce the calling convention from this information.
It is often practical to share header files between C and C++. This is an example of a declaration that declares a function with C linkage in both C and C++:
#ifdef __cplusplus extern "C" { #endif int F(int); #ifdef __cplusplus } #endif
98
Scratch registers
Any function is permitted to destroy the contents of a scratch register. If a function needs the register value after a call to another function, it must store it during the call, for example on the stack. Any of the registers R0 to R3, and R12, can be used as a scratch register by the function. Note that R12 is a scratch register also when calling between assembler functions only because of automatically inserted instructions for veneers.
Preserved registers
Preserved registers, on the other hand, are preserved across function calls. The called function can use the register for other purposes, but must save the value before using the register and restore it at the exit of the function. The registers R4 through to R11 are preserved registers. They are preserved by the called function.
Special registers
For some registers, you must consider certain prerequisites:
The stack pointer register, R13/SP, must at all times point to or below the last element on the stack. In the eventuality of an interrupt, everything below the point the stack pointer points to, can be destroyed. At function entry and exit, the stack pointer must be 8-byte aligned. In the function, the stack pointer must always be word aligned. At exit, SP must have the same value as it had at the entry. The register R15/PC is dedicated for the Program Counter. The link register, R14/LR, holds the return address at the entrance of the function.
FUNCTION ENTRANCE
Parameters can be passed to a function using one of two basic methods: in registers or on the stack. It is much more efficient to use registers than to take a detour via memory, so the calling convention is designed to use registers as much as possible. Only a limited number of registers can be used for passing parameters; when no more registers are available, the remaining parameters are passed on the stack. These exceptions to the rules apply:
Interrupt functions cannot take any parameters, except software interrupt functions that accept parameters and have return values Software interrupt functions cannot use the stack in the same way as ordinary functions. When an SVC instruction is executed, the processor switches to supervisor mode where the supervisor stack is used. Arguments can therefore not be
99
Calling convention
passed on the stack if your application is not running in supervisor mode previous to the interrupt.
Hidden parameters
In addition to the parameters visible in a function declaration and definition, there can be hidden parameters:
If the function returns a structure larger than 32 bits, the memory location where the structure is to be stored is passed as an extra parameter. Notice that it is always treated as the first parameter. If the function is a non-static C++ member function, then the this pointer is passed as the first parameter (but placed after the return structure pointer, if there is one). For more information, see Calling assembler routines from C++, page 96.
Register parameters
The registers available for passing parameters are R0R3:
Parameters Passed in registers
Scalar and floating-point values no larger than 32 bits, and Passed using the first free register: single-precision (32-bits) floating-point values R0R3 long long and double-precision (64-bit) values
Table 15: Registers used for passing parameters
The assignment of registers to parameters is a straightforward process. Traversing the parameters from left to right, the first parameter is assigned to the available register or registers. Should there be no more available registers, the parameter is passed on the stack in reverse order. When functions that have parameters smaller than 32 bits are called, the values are sign or zero extended to ensure that the unused bits have consistent values. Whether the values will be sign or zero extended depends on their typesigned or unsigned.
100
FUNCTION EXIT
A function can return a value to the function or program that called it, or it can have the return type void. The return value of a function, if any, can be scalar (such as integers and pointers), floating-point, or a structure.
Scalar and structure return values no larger than 32 bits, and single-precision (32-bit) floating-point return values The memory address of a structure return value larger than 32 bits long long and double-precision (64-bit) return values
Table 16: Registers used for returning values
R0 R0 R0:R1
101
Calling convention
If the returned value is smaller than 32 bits, the value is sign- or zero-extended to 32 bits.
{R4-R6,PC}
/* Function exit. */
EXAMPLES
The following section shows a series of declaration examples and the corresponding calling conventions. The complexity of the examples increases toward the end. Example 1 Assume this function declaration:
int add1(int);
This function takes one parameter in the register R0, and the return value is passed back to its caller in the register R0. This assembler routine is compatible with the declaration; it will return a value that is one number higher than the value of its parameter:
add1: ADDS BX R0,R0,#+0x1 BX,LR
102
Example 2 This example shows how structures are passed on the stack. Assume these declarations:
struct MyStruct { int a,b,c,d,e; }; int MyFunction(struct MyStruct x, int y);
The values of the structure members a, b, c, and d are passed in registers R0-R3. The last structure member e and the integer parameter y are passed on the stack. The calling function must reserve eight bytes on the top of the stack and copy the contents of the two stack parameters to that location. The return value is passed back to its caller in the register R0.
CFI DIRECTIVES
The CFI directives provide C-SPY with information about the state of the calling function(s). Most important of this is the return address, and the value of the stack pointer at the entry of the function or assembler routine. Given this information, C-SPY can reconstruct the state for the calling function, and thereby unwind the stack. A full description about the calling convention might require extensive call frame information. In many cases, a more limited approach will suffice. When describing the call frame information, the following three components must be present:
A names block describing the available resources to be tracked A common block corresponding to the calling convention
103
A data block describing the changes that are performed on the call frame. This typically includes information about when the stack pointer is changed, and when permanent registers are stored or restored on the stack.
This table lists all the resources defined in the names block used by the compiler:
Resource Description
The call frames of the stack Processor general-purpose 32-bit registers Stack pointer, SP Link register, LR Vector Floating Point (VFP) 32-bit coprocessor registers Current program status register Saved program status register
2 Compile the C source code, and make sure to create a list file that contains call frame
informationthe CFI directives. On the command line, use the option -lA. In the IDE, choose Project>Options>C/C++ Compiler>List and make sure the suboption Include call frame information is selected. For the source code in this example, the list file looks like this:
NAME cfiexample EXTERN F PUBLIC cfiExample
104
CFI Names cfiNames0 CFI StackFrame CFA R13 DATA CFI Resource R0:32, R1:32, R2:32, R3:32, R4:32, R5:32, R6:32, R7:32 CFI Resource R8:32, R9:32, R10:32, R11:32, R12:32, R13:32, R14:32 CFI EndNames cfiNames0 CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI CFI Common cfiCommon0 Using cfiNames0 CodeAlign 4 DataAlign 4 ReturnAddress R14 CODE CFA R13+0 R0 Undefined R1 Undefined R2 Undefined R3 Undefined R4 SameValue R5 SameValue R6 SameValue R7 SameValue R8 SameValue R9 SameValue R10 SameValue R11 SameValue R12 Undefined R14 SameValue EndCommon cfiCommon0
SECTION `.text`:CODE:NOROOT(2) CFI Block cfiBlock0 Using cfiCommon0 CFI Function cfiExample ARM cfiExample: PUSH {R4,LR} CFI R14 Frame(CFA, -4) CFI R4 Frame(CFA, -8) CFI CFA R13+8 MOVS R4,R0 MOVS R0,R4 BL F ADDS R0,R0,R4 POP {R4,LR} CFI R4 SameValue CFI R14 SameValue CFI CFA R13+0
105
;; return
Note: The header file cfiCommon.i contains the macros CFI_NAME_BLOCK, CFI_COMMON_ARM, and CFI_COMMON_Thumb which declare a typical names block and two typical common blocks. These macros declare several resources, both concrete and virtual.
106
Using C++
IAR Systems supports two levels of the C++ language: The industry-standard Embedded C++ and IAR Extended Embedded C++. They are described in this chapter.
Overview
Embedded C++ is a subset of the C++ programming language which is intended for embedded systems programming. It was defined by an industry consortium, the Embedded C++ Technical Committee. Performance and portability are particularly important in embedded systems development, which was considered when defining the language.
Classes, which are user-defined types that incorporate both data structure and behavior; the essential feature of inheritance allows data structure and behavior to be shared among classes Polymorphism, which means that an operation can behave differently on different classes, is provided by virtual functions Overloading of operators and function names, which allows several operators or functions with the same name, provided that their argument lists are sufficiently different Type-safe memory management using the operators new and delete Inline functions, which are indicated as particularly suitable for inline expansion.
C++ features that are excluded are those that introduce overhead in execution time or code size that are beyond the control of the programmer. Also excluded are late additions to the ISO/ANSI C++ standard. This is because they represent potential portability problems, due to that few development tools support the standard. Embedded C++ thus offers a subset of C++ which is efficient and fully supported by existing development tools. Standard Embedded C++ lacks these features of C++:
107
Overview
Runtime type information New cast syntax (the operators dynamic_cast, static_cast, reinterpret_cast, and const_cast) Namespaces The mutable attribute.
The exclusion of these language features makes the runtime library significantly more efficient. The Embedded C++ library furthermore differs from the full C++ library in that:
The standard template library (STL) is excluded Streams, strings, and complex numbers are supported without the use of templates Library features which relate to exception handling and runtime type information (the headers except, stdexcept, and typeinfo) are excluded.
Note: The library is not in the std namespace, because Embedded C++ does not support namespaces.
Full template support Multiple and virtual inheritance Namespace support The mutable attribute The cast operators static_cast, const_cast, and reinterpret_cast.
All these added features conform to the C++ standard. To support Extended EC++, this product includes a version of the standard template library (STL), in other words, the C++ standard chapters utilities, containers, iterators, algorithms, and some numerics. This STL is tailored for use with the Extended EC++ language, which means no exceptions, no multiple inheritance, and no support for runtime type information (rtti). Moreover, the library is not in the std namespace. Note: A module compiled with Extended EC++ enabled is fully link-compatible with a module compiled without Extended EC++ enabled.
108
Using C++
To take advantage of Extended Embedded C++ features in your source code, you must use the --eec++ compiler option. See --eec++, page 169. To set the equivalent option in the IDE, choose Project>Options>C/C++ Compiler>Language.
Feature descriptions
When you write C++ source code for the IAR C/C++ Compiler for ARM, you must be aware of some benefits and some possible quirks when mixing C++ featuressuch as classes, and class memberswith IAR language extensions, such as IAR-specific attributes.
CLASSES
A class type class and struct in C++ can have static and non-static data members, and static and non-static function members. The non-static function members can be further divided into virtual function members, non-virtual function members, constructors, and destructors. For the static data members, static function members, and non-static non-virtual function members the same rules apply as for statically linked symbols outside of a class. In other words, they can have any applicable IAR-specific type and object attribute. The non-static virtual function members can have any applicable IAR-specific type and object attribute as long as a pointer to the member function can be implicitly converted to the default function pointer type. The constructors, destructors, and non-static data members cannot have any IAR attributes. The location operator @ can be used on static data members and on any type of function members. For further information about attributes, see Type qualifiers, page 218. Example
class MyClass { public: // Locate a static variable at address 60 static __no_init int mI @ 60; // A static Thumb function static __thumb void f(); // A Thumb function __thumb void g();
109
Feature descriptions
// Interworking assumed virtual __thumb void th() // Interworking assumed virtual __arm void ah(); // Locate a virtual function into SPECIAL virtual void M() const volatile @ "SPECIAL"; };
FUNCTION TYPES
A function type with extern "C" linkage is compatible with a function that has C++ linkage. Example
extern "C" { typedef void (*FpC)(void); } typedef void (*FpCpp)(void); FpC F1; FpCpp F2; void MyF(FpC); void MyG() { MyF(F1); MyF(F2); }
// A C function typedef
TEMPLATES
Extended EC++ supports templates according to the C++ standard, except for the support of the export keyword. The implementation uses a two-phase lookup which means that the keyword typename must be inserted wherever needed. Furthermore, at each use of a template, the definitions of all possible templates must be visible. This means that the definitions of all templates must be in include files or in the actual source file.
110
Using C++
MUTABLE
The mutable attribute is supported in Extended EC++. A mutable symbol can be changed even though the whole class object is const.
NAMESPACE
The namespace feature is only supported in Extended EC++. This means that you can use namespaces to partition your code. Note, however, that the library itself is not placed in the std namespace.
You must make sure that identifiers in your application do not interfere with identifiers in the runtime library.
111
member function, make sure that all functions that should be pointed to reside in the default memory or a memory contained in the default memory. Example
class X { public: __interwork void aF(); }; void (__interwork X::*ap)() = &X::af;
In a friend declaration of a class, the class keyword can be omitted, for example:
class B; class A { friend B;
//Possible when using IAR language //extensions friend class B; //According to standard
};
According to the standard, initialized static data members should be used instead.
112
Using C++
In the declaration of a class member, a qualified name can be used, for example:
struct A { int A::F(); // Possible when using IAR language extensions int G(); // According to standard };
It is permitted to use an implicit type conversion between a pointer to a function with C linkage (extern "C") and a pointer to a function with C++ linkage (extern "C++"), for example:
extern "C" void F(); // Function with C linkage void (*PF)() // PF points to a function with C++ linkage = &F; // Implicit conversion of function pointer.
If the second or third operands in a construction that contains the ? operator are string literals or wide string literals (which in C++ are constants), the operands can be implicitly converted to char * or wchar_t *, for example:
bool X; char *P1 = X ? "abc" : "def"; //Possible when using IAR //language extensions char const *P2 = X ? "abc" : "def"; //According to standard
Default arguments can be specified for function parameters not only in the top-level function declaration, which is according to the standard, but also in typedef declarations, in pointer-to-function function declarations, and in pointer-to-member function declarations. In a function that contains a non-static local variable and a class that contains a non-evaluated expression (for example a sizeof expression), the expression can reference the non-static local variable. However, a warning is issued.
Note: If you use any of these constructions without first enabling language extensions, errors are issued.
113
114
Application-related considerations
This chapter discusses a selected range of application issues related to developing your embedded application. Typically, this chapter highlights issues that are not specifically related to only the compiler or the linker.
Note: ielftool can also be used for other types of transformations, such as filling and calculating checksums in the absolute image. The source code for ielftool is provided in the arm/src directory. For more information about ielftool, see The IAR ELF Toolielftool, page 330.
Stack considerations
The stack is used by functions to store variables and other information that is used locally by functions, as described in the chapter Data storage. It is a continuous block of memory pointed to by the processor stack pointer register SP. The data section used for holding the stack is called CSTACK. The system startup code initializes the stack pointer to the end of the stack.
115
Stack considerations
EXCEPTION STACKS
The ARM architecture supports five exception modes which are entered when different exceptions occur. Each exception mode has its own stack to avoid corrupting the System/User mode stack. The table shows proposed stack names for the various exception stacks, but any name can be used:
Proposed stack section name
Processor mode
Description
Operating system stack. Stack for general-purpose (IRQ) interrupt handlers. Stack for high-speed (FIQ) interrupt handlers. Stack for undefined instruction interrupts. Supports software emulation of hardware coprocessors and instruction set extensions. Stack for instruction fetch and data access memory abort interrupt handlers.
Abort
ABT_STACK
116
Application-related considerations
For each processor mode where a stack is needed, a separate stack pointer must be initialized in your startup code, and section placement should be done in the linker configuration file. The IRQ and FIQ stacks are the only exception stacks which are preconfigured in the supplied cstartup.s and lnkarm.icf files, but other exception stacks can easily be added. Cortex-M does not have individual exception stacks. By default, all exception stacks are placed in the CSTACK section. To view any of these stacks in the Stack window available in the IDE, these preconfigured section names must be used instead of user-defined section names.
Heap considerations
The heap contains dynamic data allocated by use of the C function malloc (or one of its relatives) or the C++ operator new. If your application uses dynamic memory allocation, you should be familiar with:
Linker sections used for the heap Allocating the heap size, see Setting up the heap, page 52.
The memory allocated to the heap is placed in the section HEAP, which is only included in the application if dynamic memory allocation is actually used.
Creating a symbol by using the ILINK command line option --define_symbol. ILINK will create a public absolute constant symbol that the application can use as a label, as a size, as setup for a debugger, et cetera.
117
Creating an exported configuration symbol by using the command line option --config_def or the configuration directive define symbol, and exporting the symbol using the export symbol directive. ILINK will create a public absolute constant symbol that the application can use as a label, as a size, as setup for a debugger, etc. One advantage of this symbol definition is that this symbol can also be used in expressions in the configuration file, for example to control the placement of sections into memory ranges.
Using the compiler operators __section_begin, __section_end, or __section_size, or the assembler operators SFB, SFE, or SIZEOF on a named section or block. These operators provide access to the start address, end address, and size of a contiguous sequence of sections with the same name, or of a linker block specified in the linker configuration file. The command line option --entry informs ILINK about the start label of the application. It is used by ILINK as a root symbol and to inform the debugger where to start execution.
The following lines illustrate how to use these mechanisms. Add these options to your command line:
--define_symbol NrOfElements=10 --config_def HeapSize=1024
118
Application-related considerations
typedef long Elements; Elements *GetElementArray() { return malloc(sizeof(Elements) * (int)& NrOfElements); } /* Use a symbol defined by ILINK option, a symbol that in the configuration file was made available to the application */ extern char HeapSize; /* Declares the section that contains our heap */ #pragma section = "MyHEAP" char *MyHeap() { /* First get start of statically allocated section */ char *p = __section_begin("MyHEAP"); /* then we zero it, using the imported size */ for (int i = 0; i < (int)& HeapSize; ++i) { p[i] = 0; } return p; }
Checksum calculation
The IAR ELF Toolielftoolfills specific ranges of memory with a pattern and then calculates a checksum for those ranges. The calculated checksum replaces the value of an existing symbol in the input ELF image. The application can then verify that the ranges did not change. To use checksumming to verify the integrity of your application, you must:
Reserve a place, with an associated name and size, for the checksum calculated by
ielftool
Choose a checksum algorithm, set up ielftool for it, and include source code for the algorithm in your application Decide what memory ranges to verify and set up both ielftool and the source code for it in your application source code.
119
Checksum calculation
CALCULATING A CHECKSUM
In this example, a checksum is calculated for ROM memory at 0x8002 up to 0x8FFF and the 2-byte calculated checksum is placed at 0x8000.
To place the .checksum section, you must modify the linker configuration file. It can look like this (note the handling of the block CHECKSUM):
define memory Mem with size = 4G; define region ROM_region = Mem:[from 0x8000 to 0x80000000 - 1]; define region RAM_region = Mem:[from 0x80000000 to 0x100000000 -2 ]; initialize by copy { rw }; do not initialize { section .noinit }; define define define define block block block block HEAP CSTACK IRQ_STACK FIQ_STACK with with with with alignment alignment alignment alignment = = = = 8, 8, 8, 8, size size size size = = = = 16M 16K 16K 16K {}; {}; {}; {};
define block CHECKSUM { ro section .checksum }; place at address Mem:0x0 { ro section .intvec}; place in ROM_region { ro, first block CHECKSUM }; place in RAM_region { rw, block HEAP, block CSTACK, block IRQ_STACK, block FIQ_STACK };
Running ielftool
To calculate the checksum, run ielftool:
ielftool --fill=0x00;0x80000x8FFF --checksum=__checksum:2,crc16;0x80000x8FFF sourceFile.out destinationFile.out
To calculate a checksum you also must define a fill operation. In this example, the fill pattern 0x0 is used. The checksum algorithm used is crc16.
120
Application-related considerations
Note that ielftool needs an unstripped input ELF image. If you use the --strip linker option, remove it and use the --strip ielftool option instead.
You can find the source code for the checksum algorithms in the arm\src\linker directory of your product installation.
Checksum calculation
This code gives an example of how the checksum can be calculated:
/* Start and end of the checksum range */ unsigned long ChecksumStart = 0x8000+2; unsigned long ChecksumEnd = 0x8FFF;
121
Checksum calculation
/* The checksum calculated by ielftool * (note that it lies on address 0x8000) */ extern unsigned short const __checksum;
void TestChecksum() { unsigned short calc = 0; unsigned char zeros[2] = {0, 0}; /* Run the checksum algorithm */ calc = slow_crc16(0, (unsigned char *) ChecksumStart, (ChecksumEnd - ChecksumStart+1)); /* Rotate out the answer */ calc = slow_crc16(calc, zeros, 2); /* Test the checksum */ if (calc != __checksum) { abort(); /* Failure */ } }
THINGS TO REMEMBER
When calculating a checksum, you must remember that:
The checksum must be calculated from the lowest to the highest address for every memory range Each memory range must be verified in the same order as defined It is OK to have several ranges for one checksum If several checksums are used, you should place them in sections with unique names and use unique symbol names If a slow function is used, you must make a final call to the checksum calculation with as many bytes (with the value 0x00) as there are bytes in the checksum.
For more information, see also The IAR ELF Toolielftool, page 330.
C-SPY CONSIDERATIONS
By default, a symbol that you have allocated in memory by using the linker option --place_holder is considered by C-SPY to be of the type int. If the size of the
122
Application-related considerations
checksum is less than four bytes, you can change the display format of the checksum symbol to match its size. In the C-SPY Watch window, select the symbol and choose Show As from the context menu. Choose the display format that matches the size of the checksum symbol.
AEABI compliance
The IAR build tools for ARM support the Embedded Application Binary Interface for ARM, AEABI, defined by ARM Limited. This interface is based on the Intel IA64 ABI interface. The advantage of adhering to AEABI is that any such module can be linked with any other AEABI compliant module, even modules produced by tools provided by other vendors. The IAR build tools for ARM support the following parts of the AEABI:
AAPCS CPPABI AAELF AADWARF RTABI CLIBABI Procedure Call Standard for the ARM architecture C++ ABI for the ARM architecture (EC++ parts only) ELF for the ARM architecture DWARF for the ARM architecture Runtime ABI for the ARM architecture C library ABI for the ARM architecture
The IAR build tools only support a bare metal platform, that is a ROM-based system that lacks an explicit operating system. Note that:
The AEABI is specified for C89 only The IAR build tools only support using the default and C locales The AEABI does not specify C++ library compatibility The IAR build tools do not support the use of exceptions and rtti Neither the size of an enum or of wchar_t is constant in the AEABI.
If AEABI compliance is enabled, almost all optimizations performed in the system header files are turned off, and certain preprocessor constants become real constant variables instead.
123
AEABI compliance
Modules produced using IAR build tools, both AEABI compliant modules as well as modules that are not AEABI compliant AEABI compliant modules produced using build tools from another vendor.
Note: To link a module produced by a compiler from another vendor, extra support libraries from that vendor might be required. The IAR ILINK Linker automatically chooses the appropriate standard C/C++ libraries to use based on attributes from the object files. Imported object files might not have all these attributes. Therefore, you might need to help ILINK choose the standard library by verifying one or more of the following details:
The used cpu by specifying the --cpu linker option If full I/O is needed; make sure to link with a Full library configuration in the standard library Explicitly specify runtime library file(s), possibly in combination with the --no_library_search linker option.
Support for the following extensions must be verified: #pragma pack, __no_init, __root, and __ramfunc The following extensions are harmless to use: #pragma location/@, __arm, __thumb, __swi, __irq, __fiq, and __nested.
124
Application-related considerations
On the command line, use the option --aeabi to enable AEABI support in the compiler. Alternatively, to enable support for AEABI for a specific system header file, you must define the preprocessor symbol _AEABI_PORTABILITY_LEVEL to non-zero prior to including a system header file, and make sure that the symbol AEABI_PORTABLE is set to non-zero after the inclusion of the header file:
#define _AEABI_PORTABILITY_LEVEL 1 #undef _AEABI_PORTABLE #include <header.h> #ifndef _AEABI_PORTABLE #error "header.h not AEABI compatible" #endif
125
AEABI compliance
126
Selecting data types Controlling data and function placement in memory Controlling compiler optimizations Facilitating good code generation.
As a part of this, the chapter also demonstrates some of the more common mistakes and how to avoid them, and gives a catalog of good coding techniques.
Use int or long instead of char or short whenever possible, to avoid sign extension or zero extension. In particular, loop indexes should always be int or long to minimize code generation. Also, in Thumb mode, accesses through the stack pointer (SP) is restricted to 32-bit data types, which further emphasizes the benefits of using one of these data types. Use unsigned data types, unless your application really requires signed values. Be aware of the costs of using 64-bit data types, such as double and long long.
127
Bitfields and packed structures generate large and slow code. Using floating-point types on a microprocessor without a math coprocessor is very inefficient, both in terms of code size and execution speed. Declaring a pointer to const data tells the calling function that the data pointed to will not change, which opens for better optimizations.
For details about representation of supported data types, pointers, and structures types, see the chapter Data representation.
FLOATING-POINT TYPES
Using floating-point types on a microprocessor without a math coprocessor is very inefficient, both in terms of code size and execution speed. Thus, you should consider replacing code that uses floating-point operations with code that uses integers, because these are more efficient. The compiler supports two floating-point formats32 and 64 bits. The 32-bit floating-point type float is more efficient in terms of code size and execution speed. However, the 64-bit format double supports higher precision and larger numbers. In the compiler, the floating-point type float always uses the 32-bit format, and the type double always uses the 64-bit format. The format used by the double floating-point type depends on the setting of the --double compiler option. Unless the application requires the extra precision that 64-bit floating-point numbers give, we recommend using 32-bit floating-point numbers instead. By default, a floating-point constant in the source code is treated as being of the type double. This can cause innocent-looking expressions to be evaluated in double precision. In the example below a is converted from a float to a double, the double constant 1.0 is added and the result is converted back to a float:
float Test(float a) { return a + 1.0; }
To treat a floating-point constant as a float rather than as a double, add the suffix f to it, for example:
float Test(float a) { return a + 1.0f; }
For more information about floating-point types, see Floating-point types, page 213.
128
Due to external demands; for example, network communication protocols are usually specified in terms of data types with no padding in between You need to save data memory.
For information about alignment requirements, see Alignment, page 209. There are two ways to solve the problem:
Use the #pragma pack directive or the __packed data type attribute for a tighter layout of the structure. The drawback is that each access to an unaligned element in the structure will use more code. Write your own customized functions for packing and unpacking structures. This is a more portable way, which will not produce any more code apart from your functions. The drawback is the need for two views on the structure datapacked and unpacked.
For further details about the #pragma pack directive, see pack, page 253.
129
Example In this example, the members in the anonymous union can be accessed, in function f, without explicitly specifying the union name:
struct S { char mTag; union { long mL; float mF; }; } St; void F(void) { St.mL = 5; }
The member names must be unique in the surrounding scope. Having an anonymous struct or union at file scope, as a global, external, or static variable is also allowed. This could for instance be used for declaring I/O registers, as in this example:
__no_init volatile union { unsigned char IOPORT; struct { unsigned char Way: 1; unsigned char Out: 1; }; } @ 0x1000;
/* Here the variables are used*/ void Test(void) { IOPORT = 0; Way = 1; Out = 1; }
This declares an I/O register byte IOPORT at address 0. The I/O register has 2 bits declared, Way and Out. Note that both the inner structure and the outer union are anonymous.
130
Anonymous structures and unions are implemented in terms of objects named after the first field, with a prefix _A_ to place the name in the implementation part of the namespace. In this example, the anonymous union will be implemented through an object named _A_IOPORT.
The @ operator and the #pragma location directive for absolute placement Use the @ operator or the #pragma location directive to place individual global and static variables at absolute addresses. The variables must be declared __no_init. This is useful for individual data objects that must be located at a fixed address, for example variables with external requirements. Note that it is not possible to use this notation for absolute placement of individual functions.
The @ operator and the #pragma location directive for section placement Use the @ operator or the #pragma location directive to place groups of functions or global and static variables in named sections, without having explicit control of each object. The sections can, for example, be placed in specific areas of memory, or initialized or copied in controlled ways using the section begin and end operators. This is also useful if you want an interface between separately linked units, for example an application project and a boot loader project. Use named sections when absolute control over the placement of individual variables is not needed, or not useful.
The --section option Use the --section option to place functions and/or data objects in named sections, which is useful, for example, if you want to direct them to different fast or slow memories. To read more about the --section option, see --section, page 186.
At compile time, data and functions are placed in different sections as described in Modules and sections, page 40. At link time, one of the most important functions of the linker is to assign load addresses to the various sections used by the application. All sections, except for the sections holding absolute located data, are automatically allocated to memory according to the specifications in the linker configuration file, as described in Placing code and datathe linker configuration file, page 42.
131
To place a variable at an absolute address, the argument to the @ operator and the #pragma location directive should be a literal number, representing the actual address. The absolute location must fulfill the alignment requirement for the variable that should be located. Note: A variable placed in an absolute location should be defined in an include file, to be included in every module that uses the variable. An unused definition in a module will be ignored. A normal extern declarationone that does not use an absolute placement directivecan refer to a variable at an absolute address; however, optimizations based on the knowledge of the absolute address cannot be performed.
Examples
In this example, a __no_init declared variable is placed at an absolute address. This is useful for interfacing between multiple processes, applications, etc:
__no_init volatile char alpha @ 0x1000;/* OK */
This example contains a const declared object which is not initialized. The object is placed in ROM. This is useful for configuration parameters, which are accessible from an external interface.
#pragma location=0x1004 __no_init const int beta; /* OK */
The actual value must be set by other means. The typical use is for configurations where the values are loaded to ROM separately, or for special function registers that are read-only. These examples show incorrect usage:
int delta @ 0x100C; __no_init int epsilon @ 0x1011; /* Error, not __no_init */ /* Error, misaligned. */
C++ considerations
In C++, module scoped const variables are static (module local), whereas in C they are global. This means that each module that declares a certain const variable will contain
132
a separate variable with this name. If you link an application with several such modules all containing (via a header file), for instance, the declaration:
volatile const __no_init int x @ 0x100; /* Bad in C++ */
the linker will report that more than one variable is located at address 0x100. To avoid this problem and make the process the same in C and C++, you should declare these variables extern, for example:
/* The extern keyword makes x public. */ extern volatile const __no_init int x @ 0x100;
Note: C++ static member variables can be placed at an absolute address just like any other static variable.
The @ operator, alternatively the #pragma location directive, can be used for placing individual variables or individual functions in named sections. The named section can either be a predefined section, or a user-defined section. The --section option can be used for placing variables and functions, which are parts of the whole compilation unit, in named sections.
C++ static member variables can be placed in named sections just like any other static variable. If you use your own sections, in addition to the predefined sections, the sections must also be defined in the linker configuration file. Note: Take care when explicitly placing a variable or function in a predefined section other than the one used by default. This is useful in some situations, but incorrect placement can result in anything from error messages during compilation and linking to a malfunctioning application. Carefully consider the circumstances; there might be strict requirements on the declaration and use of the function or variable. The location of the sections can be controlled from the linker configuration file. For more information about sections, see the chapter Section reference.
133
/* OK */
134
OPTIMIZATION LEVELS
The compiler supports different levels of optimizations. This table lists optimizations that are typically performed on each level:
Optimization level Description
Variables live through their entire scope Same as above but variables only live for as long as they are needed, not necessarily through their entire scope Same as above, and: Live-dead analysis and optimization Dead code elimination Redundant label elimination Redundant branch elimination Code hoisting Peephole optimization Some register content analysis and optimization Static clustering Common subexpression elimination
135
Optimization level
Description
Same as above, and: Instruction scheduling Cross jumping Advanced register content analysis and optimization Loop unrolling Function inlining Code motion Type-based alias analysis
Note: Some of the performed optimizations can be individually enabled or disabled. For more information about these, see Fine-tuning enabled transformations, page 136. A high level of optimization might result in increased compile time, and will most likely also make debugging more difficult, because it is less clear how the generated code relates to the source code. For example, at the low, medium, and high optimization levels, variables do not live through their entire scope, which means processor registers used for storing variables can be reused immediately after they were last used. Due to this, the C-SPY Watch window might not be able to display the value of the variable throughout its scope. At any time, if you experience difficulties when debugging your code, try lowering the optimization level.
Common subexpression elimination Loop unrolling Function inlining Code motion Type-based alias analysis
136
Loop unrolling
It is possible to duplicate the loop body of a small loop, whose number of iterations can be determined at compile time, to reduce the loop overhead. This optimization, which can be performed at optimization level High, normally reduces execution time, but increases code size. The resulting code might also be difficult to debug. The compiler heuristically decides which loops to unroll. Different heuristics are used when optimizing for speed, size, or when balancing between size and speed. Note: This option has no effect at optimization levels None, Low, and Medium. To read more about the command line option, see --no_unroll, page 180.
Function inlining
Function inlining means that a simple function, whose definition is known at compile time, is integrated into the body of its caller to eliminate the overhead of the call. This optimization, which is performed at optimization level High, normally reduces execution time, but increases code size. The resulting code might also be difficult to debug. The compiler decides which functions to inline. Different heuristics are used when optimizing for speed, size, or when balancing between size and speed. Note: This option has no effect at optimization levels None, Low, and Medium. To read more about the command line option, see --no_inline, page 178.
Code motion
Evaluation of loop-invariant expressions and common subexpressions are moved to avoid redundant re-evaluation. This optimization, which is performed at optimization
137
level High, normally reduces code size and execution time. The resulting code might however be difficult to debug. Note: This option has no effect at optimization levels None, and Low.
With type-based alias analysis, it is assumed that a write access to the short pointed to by p1 cannot affect the long value that p2 points to. Thus, it is known at compile time that this function returns 0. However, in non-standard-conforming C or C++ code these pointers could overlap each other by being part of the same union. If you use explicit casts, you can also force pointers of different pointer types to point to the same memory location.
Static clustering
When static clustering is enabled, static and global variables that are defined within the same module are arranged so that variables that are accessed in the same function are stored close to each other. This makes it possible for the compiler to use the same base pointer for several accesses.
138
Note: This option has no effect at optimization levels None and Low.
Instruction scheduling
The compiler features an instruction scheduler to increase the performance of the generated code. To achieve that goal, the scheduler rearranges the instructions to minimize the number of pipeline stalls emanating from resource conflicts within the microprocessor. Note that not all cores benefit from scheduling. Note: This option has no effect at optimization levels None, Low and Medium.
Using efficient addressing modes Helping the compiler optimize Generating more useful error message.
Local variablesauto variables and parametersare preferred over static or global variables. The reason is that the optimizer must assume, for example, that called functions can modify non-local variables. When the life spans for local variables end, the previously occupied memory can then be reused. Globally declared variables will occupy data memory during the whole program execution. Avoid taking the address of local variables using the & operator. This is inefficient for two main reasons. First, the variable must be placed in memory, and thus cannot be placed in a processor register. This results in larger and slower code. Second, the optimizer can no longer assume that the local variable is unaffected over function calls. Module-local variablesvariables that are declared staticare preferred over global variables. Also avoid taking the address of frequently accessed static variables. The compiler is capable of inlining functions. This means that instead of calling a function, the compiler inserts the content of the function at the location where the function was called. The result is a faster, but often larger, application. Also, inlining might enable further optimizations. The compiler often inlines small functions declared static. The use of the #pragma inline directive and the C++
139
keyword inline gives you fine-grained control, and it is the preferred method compared to the traditional way of using preprocessor macros. Too much inlining can decrease performance due to the limited number of registers. This feature can be disabled using the --no_inline command line option; see --no_inline, page 178.
Avoid using inline assembler. Instead, try writing the code in C or C++, use intrinsic functions, or write a separate module in assembler language. For more details, see Mixing C and assembler, page 91.
If stack space is limited, avoid long call chains and recursive functions. Avoid using large non-scalar types, such as structures, as parameters or return type. To save stack space, you should instead pass them as pointers or, in C++, as references.
FUNCTION PROTOTYPES
It is possible to declare and define functions using one of two different styles:
Both styles are included in the C standard; however, it is recommended to use the prototyped style, since it makes it easier for the compiler to find problems in the code. Using the prototyped style will also make it possible to generate more efficient code, since type promotion (implicit casting) is not needed. The K&R style is only supported for compatibility reasons. To make the compiler verify that all functions have proper prototypes, use the compiler option Require prototypes (--require_prototypes).
Prototyped style
In prototyped function declarations, the type for each parameter must be specified.
int Test(char, int); /* Declaration */ int Test(char ch, int i) /* Definition */ { return i + ch; }
140
Here, the test is always false. On the right hand side, 0x80 is 0x00000080, and ~0x00000080 becomes 0xFFFFFF7F. On the left hand side, c1 is an 8-bit unsigned character, so it cannot be larger than 255. It also cannot be negative, which means that the integral promoted value can never have the topmost 24 bits set.
141
To mark a variable properly, use the volatile keyword. This informs the compiler, among other things, that the variable can be changed from other threads. The compiler will then avoid optimizing on the variable (for example, keeping track of the variable in registers), will not delay writes to it, and be careful accessing the variable only the number of times given in the source code. To read more about the volatile type qualifier, see Declaring objects volatile, page 218.
__IO_REG32_BIT(__SYSCFG,0x03FF0000,__READ_WRITE,__syscfg_bits);
By including the appropriate include file into the user code it is possible to access either the whole register or any individual bit (or bitfields) from C code as follows:
/* whole register access */ __SYSCFG = 0x12345678; /* Bitfield accesses */ __SYSCFG_bit.we = 1; __SYSCFG_bit.cm = 3;
You can also use the header files as templates when you create new header files for other ARM devices. For details about the @ operator, see Controlling data and function placement in memory, page 131.
142
The general purpose register R0 is used for getting and setting the value of the special purpose register APSR. As the functions only contain inline assembler, the compiler will not interfere with the register usage. The register R0 is always used for return values. The first parameter is always passed in R0 if the type is 32 bits or smaller. The same method can be used also for accessing other special purpose registers and specific instructions. To read more about the risks of using inline assembler, see Inline assembler, page 93. For reference information about using inline assembler, see Inline assembler, page 225. Note: Before you use inline assembler, see if you can use an intrinsic function instead. See Summary of intrinsic functions, page 259.
NON-INITIALIZED VARIABLES
Normally, the runtime environment will initialize all global and static variables when the application is started. The compiler supports the declaration of variables that will not be initialized, using the __no_init type modifier. They can be specified either as a keyword or using the #pragma object_attribute directive. The compiler places such variables in a separate section For __no_init, the const keyword implies that an object is read-only, rather than that the object is stored in read-only memory. It is not possible to give a __no_init object an initial value.
143
Variables declared using the __no_init keyword could, for example, be large input buffers or mapped to special RAM that keeps its content even when the application is turned off. For information about the __no_init keyword, see page 239. Note that to use this keyword, language extensions must be enabled; see -e, page 169. For information about the #pragma object_attribute, see page 252.
144
External interface details Compiler options Linker options Data representation Compiler extensions Extended keywords Pragma directives Intrinsic functions The preprocessor Library functions The linker configuration file Section reference IAR utilities Implementation-defined behavior.
145
146
Invocation syntax
You can use the compiler and linker either from the IDE or from the command line. Refer to the IAR Embedded Workbench IDE User Guide for ARM for information about using the build tools from the IDE.
For example, when compiling the source file prog.c, use this command to generate an object file with debug information:
iccarm prog.c --debug
The source file can be a C or C++ file, typically with the filename extension c or cpp, respectively. If no filename extension is specified, the file to be compiled must have the extension c. Generally, the order of options on the command line, both relative to each other and to the source filename, is not significant. There is, however, one exception: when you use the -I option, the directories are searched in the same order that they are specified on the command line. If you run the compiler from the command line without any arguments, the compiler version number and all available options including brief descriptions are directed to stdout and displayed on the screen.
147
Invocation syntax
For example, when linking the object file prog.o, use this command:
ilinkarm prog.o --config configfile
If no filename extension is specified for the linker configuration file, the configuration file must have the extension icf. Generally, the order of arguments on the command line is not significant. There is, however, one exception: when you supply several libraries, the libraries are searched in the same order that they are specified on the command line. The default libraries are always searched last. The output executable image will be placed in a file named a.out, unless the -o option is used. If you run ILINK from the command line without any arguments, the ILINK version number and all available options including brief descriptions are directed to stdout and displayed on the screen.
PASSING OPTIONS
There are three different ways of passing options to the compiler and to ILINK:
Directly from the command line Specify the options on the command line after the iccarm or ilinkarm commands; see Invocation syntax, page 147.
Via environment variables The compiler and linker automatically append the value of the environment variables to every command line; see Environment variables, page 148.
Via a text file, using the -f option; see -f, page 171.
For general guidelines for the option syntax, an options summary, and a detailed description of each option, see the Compiler options chapter.
ENVIRONMENT VARIABLES
These environment variables can be used with the compiler:
Environment variable Description
C_INCLUDE
Specifies directories to search for include files; for example: C_INCLUDE=c:\program files\iar systems\embedded workbench 5.n\arm\inc;c:\headers Specifies command line options; for example: QCCARM=-lA asm.lst
QCCARM
148
ILINKARM_CMD_LINE
If the name of the #include file is an absolute path, that file is opened. If the compiler encounters the name of an #include file in angle brackets, such as:
#include <stdio.h>
it searches these directories for the file to include: 1 The directories specified with the -I option, in the order that they were specified, see -I, page 173. 2 The directories specified using the C_INCLUDE environment variable, if any, see Environment variables, page 148.
If the compiler encounters the name of an #include file in double quotes, for example:
#include "vars.h"
it searches the directory of the source file in which the #include statement occurs, and then performs the same sequence as for angle-bracketed filenames. If there are nested #include files, the compiler starts searching the directory of the file that was last included, iterating upwards for each included file, searching the source file directory last. For example:
src.c in directory dir\src #include "src.h" ... src.h in directory dir\include #include "config.h" ...
When dir\exe is the current directory, use this command for compilation:
iccarm ..\src\src.c -I..\include -I..\debugconfig
Then the following directories are searched in the order listed below for the file config.h, which in this example is located in the dir\debugconfig directory:
dir\include
149
Compiler output
File including current file (src.c). As specified with the first -I option. As specified with the second -I option.
Use angle brackets for standard header files, like stdio.h, and double quotes for files that are part of your application.
Compiler output
The compiler can produce the following output:
A linkable object file The object files produced by the compiler use the industry-standard format ELF. By default, the object file has the filename extension o.
Optional list files Various kinds of list files can be specified using the compiler option -l, see -l, page 173. By default, these files will have the filename extension lst.
Optional preprocessor output files A preprocessor output file is produced when you use the --preprocess option; by default, the file will have the filename extension i.
Diagnostic messages Diagnostic messages are directed to the standard error stream and displayed on the screen, and printed in an optional list file. To read more about diagnostic messages, see Diagnostics, page 152.
Error return codes These codes provide status information to the operating system which can be tested in a batch file, see Error return codes, page 151.
Size information Information about the generated amount of bytes for functions and data for each memory is directed to the standard output stream and displayed on the screen. Some of the bytes might be reported as shared. Shared objects are functions or data objects that are shared between modules. If any of these occur in more than one module, only one copy is retained. For example, in some cases inline functions are not inlined, which means that they are marked as shared, because only one instance of each function will be included in the final application. This mechanism is sometimes also used for compiler-generated code or data not directly associated with a particular function or variable, and when only one instance is required in the final application.
150
0 1 2 3 4
Compilation or linking successful, but there might have been warnings. Warnings were produced and the option --warnings_affect_exit_code was used. Errors occurred. Fatal errors occurred, making the tool abort. Internal errors occurred, making the tool abort.
ILINK output
ILINK can produce the following output:
An absolute executable image The final output produced by the IAR ILINK Linker is an absolute object file containing the executable image that can be put into an EPROM, downloaded to a hardware emulator, or executed on your PC using the IAR C-SPY Debugger Simulator. By default, the file has the filename extension out. The output format is always in ELF, which optionally includes debug information in the DWARF format.
Optional logging information During operation, ILINK logs its decisions on stdout, and optionally to a file. For example, if a library is searched, whether a required symbol is found in a library module, or whether a module will be part of the output. Timing information for each ILINK subsystem is also logged.
Optional map files A linker map filecontaining summaries of linkage, runtime attributes, memory, and placement, as well as an entry list can be generated by the ILINK option --map, see --map, page 200. By default, the map file has the filename extension map.
Diagnostic messages Diagnostic messages are directed to stderr and displayed on the screen, as well as printed in the optional map file. To read more about diagnostic messages, see Diagnostics, page 152.
151
Diagnostics
Error return codes ILINK returns status information to the operating system which can be tested in a batch file, see Error return codes, page 151.
Size information about used memory and amount of time Information about the generated amount of bytes for functions and data for each memory is directed to stdout and displayed on the screen.
Diagnostics
This section describes the format of the diagnostic messages and explains how diagnostic messages are divided into different levels of severity.
The name of the source file in which the issue was encountered The line number at which the compiler detected the issue The level of seriousness of the issue A unique tag that identifies the diagnostic message An explanation, possibly several lines long
Diagnostic messages are displayed on the screen, as well as printed in the optional list file. Use the option --diagnostics_tables to list all possible compiler diagnostic messages.
152
The level of seriousness of the issue A unique tag that identifies the diagnostic message An explanation, possibly several lines long
Diagnostic messages are displayed on the screen, as well as printed in the optional map file. Use the option --diagnostics_tables to list all possible linker diagnostic messages.
SEVERITY LEVELS
The diagnostic messages are divided into different levels of severity:
Remark
A diagnostic message that is produced when the compiler or linker finds a construct that can possibly lead to erroneous behavior in the generated code. Remarks are by default not issued, but can be enabled, see --remarks, page 185.
Warning
A diagnostic message that is produced when the compiler or linker finds a problem which is of concern, but not so severe as to prevent the completion of compilation or linking. Warnings can be disabled by use of the command line option --no_warnings, see page 181.
Error
A diagnostic message that is produced when the compiler or linker finds a serious error. An error will produce a non-zero exit code.
Fatal error
A diagnostic message that is produced when the compiler finds a condition that not only prevents code generation, but which makes further processing pointless. After the message is issued, compilation terminates. A fatal error will produce a non-zero exit code.
153
Diagnostics
See Summary of compiler options, page 158, for a description of the compiler options that are available for setting severity levels. For the compiler see also the chapter Pragma directives, for a description of the pragma directives that are available for setting severity levels.
INTERNAL ERROR
An internal error is a diagnostic message that signals that there was a serious and unexpected failure due to a fault in the compiler or linker. It is produced using this form:
Internal error: message
where message is an explanatory message. If internal errors occur, they should be reported to your software distributor or IAR Systems Technical Support. Include enough information to reproduce the problem, typically:
The product name The version number of the compiler or of ILINK, which can be seen in the header of the list or map files generated by the compiler or by ILINK, respectively Your license number The exact internal error message text The files involved of the application that generated the internal error A list of the options that were used when the internal error occurred.
154
Compiler options
This chapter describes the syntax of compiler options and the general syntax rules for specifying option parameters, and gives detailed reference information about each option.
Options syntax
Compiler options are parameters you can specify to change the default behavior of the compiler. You can specify options from the command linewhich is described in more detail in this sectionand from within the IDE. Refer to the IAR Embedded Workbench IDE User Guide for ARM for information about the compiler options available in the IDE and how to set them.
TYPES OF OPTIONS
There are two types of names for command line options, short names and long names. Some options have both.
A short option name consists of one character, and it can have parameters. You specify it with a single dash, for example -e A long option name consists of one or several words joined by underscores, and it can have parameters. You specify it with double dashes, for example --char_is_signed.
For information about the different methods for passing options, see Passing options, page 148.
155
Options syntax
For options with a long name and an optional parameter, any parameter should be specified with a preceding equal sign (=), for example:
--misrac2004=n
For options with a long name and a mandatory parameter, the parameter can be specified either with a preceding equal sign (=) or with a preceding space, for example:
--diagnostics_tables=MyDiagnostics.lst
or
--diagnostics_tables MyDiagnostics.lst
For short options, optional parameters are specified without a preceding space For long options, optional parameters are specified with a preceding equal sign (=) For short and long options, mandatory parameters are specified with a preceding space.
For example, a short option with an optional parameter followed by a mandatory parameter:
-lA MyList.lst
For example, a long option with an optional parameter followed by a mandatory parameter:
--preprocess=n PreprocOutput.lst
Options that take a filename as a parameter can optionally also take a path. The path can be relative or absolute. For example, to generate a listing to the file List.lst in the directory ..\listings\:
iccarm prog.c -l ..\listings\List.lst
156
Compiler options
For options that take a filename as the destination for output, the parameter can be specified as a path without a specified filename. The compiler stores the output in that directory, in a file with an extension according to the option. The filename will be the same as the name of the compiled source file, unless a different name was specified with the option -o, in which case that name is used. For example:
iccarm prog.c -l ..\listings\
The produced list file will have the default name ..\listings\prog.lst
By specifying -, input files and output files can be redirected to the standard input and output stream, respectively. For example:
iccarm prog.c -l -
Additional rules
These rules also apply:
When an option takes a parameter, the parameter cannot start with a dash (-) followed by another character. Instead, you can prefix the parameter with two dashes; this example will create a list file called -r:
iccarm prog.c -l ---r
For options that accept multiple arguments of the same type, the arguments can be provided as a comma-separated list (without a space), for example:
--diag_warning=Be0001,Be0002
Alternatively, the option can be repeated for each argument, for example:
--diag_warning=Be0001 --diag_warning=Be0002
157
--aapcs --aeabi --align_sp_on_irq --arm --char_is_signed --cpu --cpu_mode -D --debug --dependencies --diag_error --diag_remark --diag_suppress --diag_warning --diagnostics_tables --discard_unused_publics --dlib_config -e --ec++ --eec++ --enable_hardware_workaround --enable_multibytes --endian --enum_is_int --error_limit -f
Table 23: Compiler options summary
Specifies the calling convention Enables AEABI-compliant code generation Generates code to align SP on entry to __irq functions Sets the default function mode to ARM Treats char as signed Specifies a processor variant Selects the default mode for functions Defines preprocessor symbols Generates debug information Lists file dependencies Treats these as errors Treats these as remarks Suppresses these diagnostics Treats these as warnings Lists all diagnostic messages Discards unused public symbols Determines the library configuration file Enables language extensions Enables Embedded C++ syntax Enables Extended Embedded C++ syntax Enables a specific hardware workaround Enables support for multibyte characters in source files Specifies the byte order of the generated code and data Sets the minimum size on enumeration types Specifies the allowed number of errors before compilation stops Extends the command line
158
Compiler options
Description
Selects the type of floating-point unit Lists all referred source files and header files Specifies include file path Generates interworking code Creates a list file Generates object code linkable with older tool chains Enables multi file compilation Extends the preprocessor Enables error messages specific to MISRA-C:1998. See the IAR Embedded Workbench MISRA C:1998 Reference Guide. Enables error messages specific to MISRA-C:2004. See the IAR Embedded Workbench MISRA C:2004 Reference Guide. Enables verbose logging of MISRA C checking. See the IAR Embedded Workbench MISRA C:1998 Reference Guide or the IAR Embedded Workbench MISRA C:2004 Reference Guide. Disables static clustering optimizations Disables code motion optimization Disables the alignment optimization for constants. Disables common subexpression elimination Disables section fragment handling Disables guard calls for static initializers Disables function inlining Removes the path from the return value of the symbols __FILE__ and __BASE_FILE__ Disables the instruction scheduler Disables type-based alias analysis Disables the use of typedef names in diagnostics Avoids unaligned accesses Disables loop unrolling
--misrac2004
--misrac_verbose
--no_clustering --no_code_motion --no_const_align --no_cse --no_fragments --no_guard_calls --no_inline --no_path_in_file_macros --no_scheduling --no_tbaa --no_typedefs_in_diagnostics --no_unaligned_access --no_unroll
Table 23: Compiler options summary (Continued)
159
Descriptions of options
Description
--no_warnings --no_wrap_diagnostics -O -o --only_stdout --output --predef_macros --preinclude --preprocess --public_equ -r --remarks --require_prototypes --section --separate_cluster_for_ initialized_variables --silent --strict_ansi --thumb --use_unix_directory_ separators --warnings_affect_exit_code --warnings_are_errors
Table 23: Compiler options summary (Continued)
Disables all warnings Disables wrapping of diagnostic messages Sets the optimization level Sets the object filename Uses standard output only Sets the object filename Lists the predefined symbols. Includes an include file before reading the source file Generates preprocessor output Defines a global named assembler label Generates debug information Enables remarks Verifies that functions are declared before they are defined Changes a section name Separates initialized and non-initialized variables Sets silent operation Checks for strict compliance with ISO/ANSI C Sets default function mode to Thumb Uses / as directory separator in paths Warnings affects exit code Warnings are treated as errors
Descriptions of options
The following section gives detailed reference information about each compiler option. Note that if you use the options page Extra Options to specify specific command line options, the IDE does not perform an instant check for consistency problems like conflicting options, duplication of options, or use of irrelevant options.
160
Compiler options
--aapcs
Syntax Parameters
std Processor registers are used for floating-point parameters and return values in function calls according to standard AAPCS. std is the default when the --aeabi compiler option is used or the software FPU is selected. Note that this calling convention enables guard calls. VFP registers are used for floating-point parameters and return values. The generated code is not compatible with AEABI code. vfp is the default when a VFP is selected and --aeabi is not used. --aapcs={std|vfp}
vfp
Description
Use this option to specify the calling convention. Project>Options>C/C++ Compiler>Extra Options.
--aeabi
Syntax Description See also
--aeabi
Use this option to generate AEABI compliant object code. AEABI compliance, page 123 and --no_guard_calls, page 177. Project>Options>C/C++ Compiler>Extra Options.
--align_sp_on_irq
Syntax Description See also
--align_sp_on_irq
Use this option to align the stack pointer (SP) on entry to __irq declared functions. __irq, page 238. Project>Options>C/C++ Compiler>Extra Options.
161
Descriptions of options
--arm
Syntax Description
--arm
Use this option to set default function mode to ARM. This setting must be the same for all files included in a program, unless they are interworking. Note: This option has the same effect as the --cpu_mode=arm option.
See also
--interwork, page 173 and __interwork, page 238. Project>Options>General Options>Target>Processor mode>Arm
--char_is_signed
Syntax Description
--char_is_signed
By default, the compiler interprets the char type as unsigned. Use this option to make the compiler interpret the char type as signed instead. This can be useful when you, for example, want to maintain compatibility with another compiler. Note: The runtime library is compiled without the --char_is_signed option. If you use this option, you might get type mismatch warnings from the linker, because the library uses unsigned char. Project>Options>C/C++ Compiler>Language>Plain char is
--cpu
Syntax Parameters
core Specifies a specific processor variant --cpu=core
Description
Use this option to select the processor variant for which the code is to be generated. The default is ARM7TDMI. The following cores and processor macrocells are recognized:
162
Compiler options
ARM920T ARM922T ARM940T ARM9E ARM9E-S ARM926EJ-S ARM946E-S ARM966E-S ARM968E-S ARM10E ARM1020E ARM1022E ARM1026EJ-S ARM1136J ARM1136J-S ARM1136JF ARM1136JF-S ARM1176J ARM1176J-S ARM1176JF ARM1176JF-S Cortex-M0 Cortex-M1 Cortex-Ms1* Cortex-M3 Cortex-R4 XScale XScale-IR7.
See also
--cpu_mode
Syntax Parameters
arm, a (default) thumb, t Selects the arm mode as the default mode for functions Selects the thumb mode as the default mode for functions --cpu_mode={arm|a|thumb|t}
Description
Use this option to select the default mode for functions. This setting must be the same for all files included in a program, unless they are interworking.
163
Descriptions of options
See also
--interwork, page 173 and __interwork, page 238. Project>Options>General Options>Target>Processor mode
-D
Syntax Parameters
symbol value The name of the preprocessor symbol The value of the preprocessor symbol -D symbol[=value]
Description
Use this option to define a preprocessor symbol. If no value is specified, 1 is used. This option can be used one or more times on the command line. The option -D has the same effect as a #define statement at the top of the source file:
-Dsymbol
is equivalent to:
#define symbol 1
--debug, -r
Syntax
--debug -r
Description
Use the --debug or -r option to make the compiler include information in the object modules required by the IAR C-SPY Debugger and other symbolic debuggers. Note: Including debug information will make the object files larger than otherwise. Project>Options>C/C++ Compiler>Output>Generate debug information
164
Compiler options
--dependencies
Syntax Parameters
i (default) m Lists only the names of files Lists in makefile style --dependencies[=[i|m]] {filename|directory}
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. Description Use this option to make the compiler list all source and header files opened by the compilation into a file with the default filename extension i. If --dependencies or --dependencies=i is used, the name of each opened source file, including the full path, if available, is output on a separate line. For example:
c:\iar\product\include\stdio.h d:\myproject\include\foo.h
Example
If --dependencies=m is used, the output uses makefile style. For each source file, one line containing a makefile dependency rule is produced. Each line consists of the name of the object file, a colon, a space, and the name of a source file. For example:
foo.o: c:\iar\product\include\stdio.h foo.o: d:\myproject\include\foo.h
An example of using --dependencies with a popular make utility, such as gmake (GNU make):
That is, in addition to producing an object file, the command also produces a dependency file in makefile style (in this example, using the extension .d).
2 Include all the dependency files in the makefile using, for example:
-include $(sources:.c=.d)
Because of the dash (-) it works the first time, when the .d files do not yet exist. This option is not available in the IDE.
165
Descriptions of options
--diag_error
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117 --diag_error=tag[,tag,...]
Description
Use this option to reclassify certain diagnostic messages as errors. An error indicates a violation of the C or C++ language rules, of such severity that object code will not be generated. The exit code will be non-zero. This option may be used more than once on the command line. Project>Options>C/C++ Compiler>Diagnostics>Treat these as errors
--diag_remark
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe177 --diag_remark=tag[,tag,...]
Description
Use this option to reclassify certain diagnostic messages as remarks. A remark is the least severe type of diagnostic message and indicates a source code construction that may cause strange behavior in the generated code. This option may be used more than once on the command line. Note: By default, remarks are not displayed; use the --remarks option to display them. Project>Options>C/C++ Compiler>Diagnostics>Treat these as remarks
166
Compiler options
--diag_suppress
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117 --diag_suppress=tag[,tag,...]
Description
Use this option to suppress certain diagnostic messages. These messages will not be displayed. This option may be used more than once on the command line. Project>Options>C/C++ Compiler>Diagnostics>Suppress these diagnostics
--diag_warning
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe826 --diag_warning=tag[,tag,...]
Description
Use this option to reclassify certain diagnostic messages as warnings. A warning indicates an error or omission that is of concern, but which will not cause the compiler to stop before compilation is completed. This option may be used more than once on the command line. Project>Options>C/C++ Compiler>Diagnostics>Treat these as warnings
--diagnostics_tables
Syntax Parameters
--diagnostics_tables {filename|directory}
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156.
167
Descriptions of options
Description
Use this option to list all possible diagnostic messages in a named file. This can be convenient, for example, if you have used a pragma directive to suppress or change the severity level of any diagnostic messages, but forgot to document why. This option cannot be given together with other options. This option is not available in the IDE.
--discard_unused_publics
Syntax Description
--discard_unused_publics
Use this option to discard unused public functions and variables from the compilation unit. This enhances interprocedural optimizations such as inlining, cross call, and cross jump by limiting their scope to public functions and variables that are actually used. This option is only useful when all source files are compiled as one unit, which means that the --mfc compiler option is used. Note: Do not use this option only on parts of the application, as necessary symbols might be removed from the generated output.
See also
--mfc, page 175 and Multi-file compilation units, page 135. Project>Options>C/C++ Compiler>Discard unused publics
--dlib_config
Syntax Parameters
--dlib_config filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Each runtime library has a corresponding library configuration file. Use this option to specify the library configuration file for the compiler. Make sure that you specify a configuration file that corresponds to the library you are using. All prebuilt runtime libraries are delivered with corresponding configuration files. You can find the library object files and the library configuration files in the directory arm\lib. For examples and a list of prebuilt runtime libraries, see Using a prebuilt library, page 64.
Description
168
Compiler options
If you build your own customized runtime library, you should also create a corresponding customized library configuration file, which must be specified to the compiler. For more information, see Building and using a customized library, page 71. To set related options, choose: Project>Options>General Options>Library Configuration
-e
Syntax Description
-e
In the command line version of the compiler, language extensions are disabled by default. If you use language extensions such as extended keywords and anonymous structs and unions in your source code, you must use this option to enable them. Note: The -e option and the --strict_ansi option cannot be used at the same time.
See also
The chapter Compiler extensions. Project>Options>C/C++ Compiler>Language>Allow IAR extensions Note: By default, this option is enabled in the IDE.
--ec++
Syntax Description
--ec++
In the compiler, the default language is C. If you use Embedded C++, you must use this option to set the language the compiler uses to Embedded C++. Project>Options>C/C++ Compiler>Language>Embedded C++
--eec++
Syntax Description
--eec++
In the compiler, the default language is C. If you take advantage of Extended Embedded C++ features like namespaces or the standard template library in your source code, you must use this option to set the language the compiler uses to Extended Embedded C++.
169
Descriptions of options
See also
--enable_hardware_workaround
Syntax Parameters
waid The ID number of the workaround to enable. For a list of available workarounds to enable, see the release notes. --enable_hardware_workaround=waid[,waid[...]]
Description
Use this option to make the compiler generate a workaround for a specific hardware problem. The release notes for a list of available parameters. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
See also
--enable_multibytes
Syntax Description
--enable_multibytes
By default, multibyte characters cannot be used in C or C++ source code. Use this option to make multibyte characters in the source code be interpreted according to the host computers default setting for multibyte support. Multibyte characters are allowed in C and C++ style comments, in string literals, and in character constants. They are transferred untouched to the generated code. Project>Options>C/C++ Compiler>Language>Enable multibyte support
--endian
Syntax Parameters
big, b little, l (default) Specifies big endian as the default byte order Specifies little endian as the default byte order --endian={big|b|little|l}
170
Compiler options
Description
Use this option to specify the byte order of the generated code and data. By default, the compiler generates code in little-endian byte order. Byte order, page 21, Byte order, page 210, --BE8, page 191, and --BE32, page 191. Project>Options>General Options>Target>Endian mode
See also
--enum_is_int
Syntax Description
--enum_is_int
Use this option to force the size of all enumeration types to be at least 4 bytes. Note: This option will not consider the fact that an enum type can be larger than an integer type.
See also
The enum type, page 211. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
--error_limit
Syntax Parameters
n The number of errors before the compiler stops the compilation. n must be a positive integer; 0 indicates no limit. --error_limit=n
Description
Use the --error_limit option to specify the number of errors allowed before the compiler stops the compilation. By default, 100 errors are allowed. This option is not available in the IDE.
-f
Syntax Parameters
-f filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156.
171
Descriptions of options
Descriptions
Use this option to make the compiler read command line options from the named file, with the default filename extension xcl. In the command file, you format the items exactly as if they were on the command line itself, except that you may use multiple lines, because the newline character acts just as a space or tab character. Both C and C++ style comments are allowed in the file. Double quotes behave in the same way as in the Microsoft Windows command line environment. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
--fpu
Syntax Parameters
VFPv1 For a vector floating-point unit conforming to the architecture VFPv1. For a system that implements a VFP unit conforming to the architecture VFPv2. VFP9-S is an implementation of the VFPv2 architecture that can be used with the ARM9E family of CPU cores. Selecting the VFP9-S coprocessor is therefore identical to selecting the VFPv2 architecture. The software floating-point library is used. --fpu={VFPv1|VFPv2|VFP9-S|none}
VFPv2
VFP9-S
none (default)
Description
Use this option to generate code that carries out floating-point operations using a Vector Floating Point (VFP) coprocessor. By selecting a VFP coprocessor, you will override the use of the software floating-point library for all supported floating-point operations. VFP and floating-point arithmetic, page 21. Project>Options>General Options>Target>FPU
See also
--header_context
Syntax Description
--header_context
Occasionally, to find the cause of a problem it is necessary to know which header file that was included from which source line. Use this option to list, for each diagnostic
172
Compiler options
message, not only the source position of the problem, but also the entire include stack at that point. This option is not available in the IDE.
-I
Syntax Parameters
path The search path for #include files -I path
Description
Use this option to specify the search paths for #include files. This option can be used more than once on the command line. Include file search procedure, page 149. Project>Options>C/C++ Compiler>Preprocessor>Additional include directories
See also
--interwork
Syntax Description
--interwork
Use this option to generate interworking code. In code compiled with this option, functions will by default be of the type interwork. It will be possible to mix files compiled as arm and thumb (using the --cpu_mode option) as long as they are all compiled with the --interwork option. Note: Source code compiled for an ARM architecture v5 or higher, or AEABI compliance is interworking by default. Project>Options>General Options>Target>Generate interwork code
-l
Syntax Parameters
a (default) A Assembler list file Assembler list file with C or C++ source as comments -l[a|A|b|B|c|C|D][N][H] {filename|directory}
173
Descriptions of options
Basic assembler list file. This file has the same contents as a list file produced with -la, except that no extra compiler-generated information (runtime model attributes, call frame information, frame size information) is included * Basic assembler list file. This file has the same contents as a list file produced with -lA, except that no extra compiler generated information (runtime model attributes, call frame information, frame size information) is included * C or C++ list file C or C++ list file with assembler source as comments C or C++ list file with assembler source as comments, but without instruction offsets and hexadecimal byte values No diagnostics in file Include source lines from header files in output. Without this option, only source lines from the primary source file are included
c C (default) D
N H
* This makes the list file less useful as input to the assembler, but more useful for reading by a human.
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. Description Use this option to generate an assembler or C/C++ listing to a file. Note that this option can be used one or more times on the command line. To set related options, choose: Project>Options>C/C++ Compiler>List
--legacy
Syntax Parameters
RVCT3.0 Generates object code linkable with the linker in RVCT3.0. Use this mode together with the --aeabi option to export code that should be linked with the linker in RVCT3.0. --legacy={mode}
Description
Use this option to generate code compatible with older tool chains. Project>Options>C/C++ Compiler>Extra Options.
174
Compiler options
--mfc
Syntax Description
--mfc
Use this option to enable multi-file compilation. This means that the compiler compiles one or several source files specified on the command line as one unit, which makes interprocedural optimizations such as inlining, cross call, and cross jump possible. Note: The compiler will generate one object file per input source code file, where the first object file contains all relevant data and the other ones are empty. If you want only the first file to be produced, use the -o compiler option and specify a certain output file.
--discard_unused_publics, page 168, -o, --output, page 182, and Multi-file compilation units, page 135. Project>Options>C/C++ Compiler>Multi-file compilation
--migration_preprocessor_extensions
Syntax Description
--migration_preprocessor_extensions
If you need to migrate code from an earlier IAR Systems C or C/C++ compiler, you might want to use this option. Use this option to use the following in preprocessor expressions:
Floating-point expressions Basic type names and sizeof All symbol names (including typedefs and variables).
Note: If you use this option, not only will the compiler accept code that does not conform to the ISO/ANSI C standard, but it will also reject some code that does conform to the standard. Important! Do not depend on these extensions in newly written code, because support for them might be removed in future compiler versions. Project>Options>C/C++ Compiler>Language>Enable IAR migration preprocessor extensions
175
Descriptions of options
--no_clustering
Syntax Description
--no_clustering
Use this option to disable static clustering optimizations. When static clustering is enabled, static and global variables are arranged so that variables that are accessed in the same function are stored close to each other. This makes it possible for the compiler to use the same base pointer for several accesses. These optimizations, which are performed at optimization levels Medium and High, normally reduce code size and execution time. Note: This option has no effect at optimization levels below Medium. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Static clustering
--no_code_motion
Syntax Description
--no_code_motion
Use this option to disable code motion optimizations. These optimizations, which are performed at the optimization levels Medium and High, normally reduce code size and execution time. However, the resulting code might be difficult to debug. Note: This option has no effect at optimization levels below Medium. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Code motion
--no_const_align
Syntax Description
--no_const_align
By default, the compiler uses alignment 4 for objects with a size of 4 bytes or more. Use this option to make the compiler align const objects based on the alignment of their type. For example, a string literal will get alignment 1, because it is an array with elements of the type const char which has alignment 1. Using this option might save ROM space, possibly at the expense of processing speed.
176
Compiler options
See also
Alignment, page 209. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
--no_cse
Syntax Description
--no_cse
Use this option to disable common subexpression elimination. At the optimization levels Medium and High, the compiler avoids calculating the same expression more than once. This optimization normally reduces both code size and execution time. However, the resulting code might be difficult to debug. Note: This option has no effect at optimization levels below Medium. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Common subexpression elimination
--no_fragments
Syntax Description
--no_fragments
Use this option to disable section fragment handling. Normally, the toolset uses IAR proprietary information for transferring section fragment information to the linker. The linker uses this information to remove unused code and data, and thus further minimize the size of the executable image. The effect of using this option in the compiler is smaller object size. Keeping symbols and sections, page 52. To set this option, use Project>Options>C/C++ Compiler>Extra Options
See also
--no_guard_calls
Syntax Description
--no_guard_calls
If the --aeabi compiler option is used, the compiler produces extra library calls that guard the initialization of static variables in file scope. These library calls are only meaningful in an OS environment where you must make sure that these variables are not initialized by another concurrent process at the same time. Use this option to remove these library calls.
177
Descriptions of options
Note: To be AEABI compliant, this option must not be used. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
--no_inline
Syntax Description
--no_inline
Use this option to disable function inlining. Function inlining means that a simple function, whose definition is known at compile time, is integrated into the body of its caller to eliminate the overhead of the call. This optimization, which is performed at optimization level High, normally reduces execution time and increases code size. The resulting code might also be difficult to debug. The compiler heuristically decides which functions to inline. Different heuristics are used when optimizing for speed than for size. Note: This option has no effect at optimization levels below High. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Function inlining
--no_path_in_file_macros
Syntax Description
--no_path_in_file_macros
Use this option to exclude the path from the return value of the predefined preprocessor symbols __FILE__ and __BASE_FILE__. Descriptions of predefined preprocessor symbols, page 284. This option is not available in the IDE.
See also
--no_scheduling
Syntax Description
--no_scheduling
Use this option to disable the instruction scheduler. The compiler features an instruction scheduler to increase the performance of the generated code. To achieve that goal, the scheduler rearranges the instructions to minimize the number of pipeline stalls
178
Compiler options
emanating from resource conflicts within the microprocessor. This optimization, which is performed at optimization level High, normally reduce execution time. However, the resulting code might be difficult to debug. Note: This option has no effect at optimization levels below High. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Instruction scheduling
--no_tbaa
Syntax Description
--no_tbaa
Use this option to disable type-based alias analysis. When this options is not used, the compiler is free to assume that objects are only accessed through the declared type or through unsigned char. Type-based alias analysis, page 138. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Type-based alias analysis
See also
--no_typedefs_in_diagnostics
Syntax Description
--no_typedefs_in_diagnostics
Use this option to disable the use of typedef names in diagnostics. Normally, when a type is mentioned in a message from the compiler, most commonly in a diagnostic message of some kind, the typedef names that were used in the original declaration are used whenever they make the resulting text shorter.
typedef int (*MyPtr)(char const *); MyPtr p = "foo";
Example
179
Descriptions of options
If the --no_typedefs_in_diagnostics option is used, the error message will be like this:
Error[Pe144]: a value of type "char *" cannot be used to initialize an entity of type "int (*)(char const *)"
--no_unaligned_access
Syntax Description
--no_unaligned_access
Use this option to make the compiler avoid unaligned accesses. Data accesses are usually performed aligned for improved performance. However, some accesses, most notably when reading from or writing to packed data structures, may be unaligned. When using this option, all such accesses will be performed using a smaller data size to avoid any unaligned accesses. This option is only useful for ARMv6 architectures and higher. --interwork, page 173 and __interwork, page 238. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
See also
--no_unroll
Syntax Description
--no_unroll
Use this option to disable loop unrolling. The code body of a small loop, whose number of iterations can be determined at compile time, is duplicated to reduce the loop overhead. For small loops, the overhead required to perform the looping can be large compared with the work performed in the loop body. The loop unrolling optimization duplicates the body several times, reducing the loop overhead. The unrolled body also opens up for other optimization opportunities. This optimization, which is performed at optimization level High, normally reduces execution time, but increases code size. The resulting code might also be difficult to debug. The compiler heuristically decides which loops to unroll. Different heuristics are used when optimizing for speed and size.
180
Compiler options
Note: This option has no effect at optimization levels below High. Project>Options>C/C++ Compiler>Optimizations>Enable transformations>Loop unrolling
--no_warnings
Syntax Description
--no_warnings
By default, the compiler issues warning messages. Use this option to disable all warning messages. This option is not available in the IDE.
--no_wrap_diagnostics
Syntax Description
--no_wrap_diagnostics
By default, long lines in diagnostic messages are broken into several lines to make the message easier to read. Use this option to disable line wrapping of diagnostic messages. This option is not available in the IDE.
-O
Syntax Parameters
n l (default) m h hs hz None* (Best debug support) Low* Medium High, balanced High, favoring speed High, favoring size -O[n|l|m|h|hs|hz]
*The most important difference between None and Low is that at None, all non-static variables will live during their entire scope.
181
Descriptions of options
Description
Use this option to set the optimization level to be used by the compiler when optimizing the code. If no optimization option is specified, the optimization level Low is used by default. If only -O is used without any parameter, the optimization level High balanced is used. A low level of optimization makes it relatively easy to follow the program flow in the debugger, and, conversely, a high level of optimization makes it relatively hard.
See also
-o, --output
Syntax
-o {filename|directory} --output {filename|directory}
Parameters
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. By default, the object code output produced by the compiler is located in a file with the same name as the source file, but with the extension o. Use this option to explicitly specify a different output filename for the object code output. This option is not available in the IDE.
Description
--only_stdout
Syntax Description
--only_stdout
Use this option to make the compiler use the standard output stream (stdout) also for messages that are normally directed to the error output stream (stderr). This option is not available in the IDE.
182
Compiler options
--output, -o
Syntax
--output {filename|directory} -o {filename|directory}
Parameters
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. By default, the object code output produced by the compiler is located in a file with the same name as the source file, but with the extension o. Use this option to explicitly specify a different output filename for the object code output. This option is not available in the IDE.
Description
--predef_macros
Syntax Parameters
--predef_macros {filename|directory}
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Use this option to list the predefined symbols. When using this option, make sure to also use the same options as for the rest of your project. If a filename is specified, the compiler stores the output in that file. If a directory is specified, the compiler stores the output in that directory, in a file with the predef filename extension. Note that this option requires that you specify a source file on the command line. This option is not available in the IDE.
Description
--preinclude
Syntax Parameters
--preinclude includefile
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156.
183
Descriptions of options
Description
Use this option to make the compiler include the specified include file before it starts to read the source file. This is useful if you want to change something in the source code for the entire application, for instance if you want to define a new symbol. Project>Options>C/C++ Compiler>Preprocessor>Preinclude file
--preprocess
Syntax Parameters
c n l Preserve comments Preprocess only Generate #line directives --preprocess[=[c][n][l]] {filename|directory}
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. Description Use this option to generate preprocessed output to a named file. Project>Options>C/C++ Compiler>Preprocessor>Preprocessor output to file
--public_equ
Syntax Parameters
symbol value The name of the assembler symbol to be defined An optional value of the defined assembler symbol --public_equ symbol[=value]
Description
This option is equivalent to defining a label in assembler language using the EQU directive and exporting it using the PUBLIC directive. This option can be used more than once on the command line. This option is not available in the IDE.
184
Compiler options
-r, --debug
Syntax
-r --debug
Description
Use the -r or the --debug option to make the compiler include information in the object modules required by the IAR C-SPY Debugger and other symbolic debuggers. Note: Including debug information will make the object files larger than otherwise. Project>Options>C/C++ Compiler>Output>Generate debug information
--remarks
Syntax Description
--remarks
The least severe diagnostic messages are called remarks. A remark indicates a source code construct that may cause strange behavior in the generated code. By default, the compiler does not generate remarks. Use this option to make the compiler generate remarks. Severity levels, page 153. Project>Options>C/C++ Compiler>Diagnostics>Enable remarks
See also
--require_prototypes
Syntax Description
--require_prototypes
Use this option to force the compiler to verify that all functions have proper prototypes. Using this option means that code containing any of the following will generate an error:
A function call of a function with no declaration, or with a Kernighan & Ritchie C declaration A function definition of a public function with no previous prototype declaration An indirect function call through a function pointer with a type that does not include a prototype.
Note: This option only applies to functions in the C standard library. Project>Options>C/C++ Compiler>Language>Require prototypes
185
Descriptions of options
--section
Syntax Description
--section OldName=NewName
The compiler places functions and data objects into named sections which are referred to by the IAR ILINK Linker. Use this option to change the name of the section OldName to NewName. This is useful if you want to place your code or data in different address ranges and you find the @ notation, alternatively the #pragma location directive, insufficient. Note that any changes to the section names require corresponding modifications in the linker configuration file.
Example
See also
For information about the different methods for controlling placement of data and code, see Controlling data and function placement in memory, page 131. Project>Options>C/C++ Compiler>Output>Code section name
--separate_cluster_for_initialized_variables
Syntax Description
--separate_cluster_for_initialized_variables
Use this option to separate initialized and non-initialized variables when using variable clustering. This might reduce the number of bytes in the ROM area which are needed for data initialization, but it might lead to larger code. This option can be useful if you want to have your own data initialization routine, but want the IAR tools to arrange for the zero-initialized variables.
See also
Manual initialization, page 54 and Initialize directive, page 305. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
186
Compiler options
--silent
Syntax Description
--silent
By default, the compiler issues introductory messages and a final statistics report. Use this option to make the compiler operate without sending these messages to the standard output stream (normally the screen). This option does not affect the display of error and warning messages. This option is not available in the IDE.
--strict_ansi
Syntax Description
--strict_ansi
By default, the compiler accepts a relaxed superset of ISO/ANSI C/C++, see Minor language extensions, page 228. Use this option to ensure that the program conforms to the ISO/ANSI C/C++ standard. Note: The -e option and the --strict_ansi option cannot be used at the same time. Project>Options>C/C++ Compiler>Language>Language conformances>Strict ISO/ANSI
--thumb
Syntax Description
--thumb
Use this option to set default function mode to Thumb. This setting must be the same for all files included in a program, unless they are interworking. Note: This option has the same effect as the --cpu_mode=thumb option.
See also
--interwork, page 173 and __interwork, page 238. Project>Options>General Options>Target>Processor mode>Arm
187
Descriptions of options
--use_unix_directory_separators
Syntax Description
--use_unix_directory_separators
Use this option to make DWARF debug information use / (instead of \) as directory separators in paths. This option can be useful if you have a debugger that requires directory separators in UNIX style. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
--warnings_affect_exit_code
Syntax Description
--warnings_affect_exit_code
By default, the exit code is not affected by warnings, because only errors produce a non-zero exit code. With this option, warnings will also generate a non-zero exit code. This option is not available in the IDE.
--warnings_are_errors
Syntax Description
--warnings_are_errors
Use this option to make the compiler treat all warnings as errors. If the compiler encounters an error, no object code is generated. Warnings that have been changed into remarks are not treated as errors. Note: Any diagnostic messages that have been reclassified as warnings by the option --diag_warning or the #pragma diag_warning directive will also be treated as errors when --warnings_are_errors is used.
See also
188
Linker options
This chapter gives detailed reference information about each linker option. For general syntax rules, see Options syntax, page 155.
--BE8 --BE32 --config --config_def --cpp_init_routine --cpu --define_symbol --diag_error --diag_remark --diag_suppress --diag_warning --diagnostics_tables --entry --error_limit --export_builtin_config -f --force_output --image_input --keep --log
Table 24: Linker options summary
Uses the big-endian format BE8 Uses the big-endian format BE32 Specifies the linker configuration file to be used by the linker Defines symbols for the configuration file Specifies a user-defined C++ dynamic initialization routine Specifies a processor variant Defines symbols that can be used by the application Treats these message tags as errors Treats these message tags as remarks Suppresses these diagnostic messages Treats these message tags as warnings Lists all diagnostic messages Treats the symbol as a root symbol and as the start of the application Specifies the allowed number of errors before compilation stops Produces an icf file for the default configuration Extends the command line Produces an output file even if errors occurred Puts an image file in a section Forces a symbol to be included in the application Enables log output for selected topics
189
Description
Directs the log to a file Adds mangled names in messages Produces a map file Enables error messages specific to MISRA-C:1998. See the IAR Embedded Workbench MISRA C:1998 Reference Guide. Enables error messages specific to MISRA-C:2004. See the IAR Embedded Workbench MISRA C:2004 Reference Guide. Enables verbose logging of MISRA C checking. See the IAR Embedded Workbench MISRA C:1998 Reference Guide and the IAR Embedded Workbench MISRA C:2004 Reference Guide. Disables section fragment handling Disables automatic runtime library search Removes local symbols from the ELF executable image. Disables removal of unused sections Disables generation of veneers Disables generation of warnings Does not wrap long lines in diagnostic messages Sets the object filename Uses standard output only Produces an OSE load module image Sets the object filename Generates position independent veneers. Reserve a place in ROM to be filled by some other tool, for example a checksum calculated by ielftool. Redirects a reference to a symbol to another symbol Enables remarks Links with debug interface Sets silent operation
--misrac2004
--misrac_verbose
--no_fragments --no_library_search --no_locals --no_remove --no_veneers --no_warnings --no_wrap_diagnostics -o --only_stdout --ose_load_module --output --pi_veneers --place_holder
190
Linker options
Description
Removes debug information from the executable image Warnings are treated as errors Warnings affects exit code
Descriptions of options
The following section gives detailed reference information about each compiler and linker option. Note that if you use the options page Extra Options to specify specific command line options, the IDE does not perform an instant check for consistency problems like conflicting options, duplication of options, or use of irrelevant options.
--BE8
Syntax Description
--BE8
Use this option to specify the Byte Invariant Addressing mode. This means that the linker reverses the byte order of the instructions, resulting in little-endian code and big-endian data. This is the default byte addressing mode for ARMv6 big-endian images. This is the only mode available for ARM v6M and ARM v7 with big-endian images. Byte Invariant Addressing mode is only available on ARM processors that support ARMv6, ARM v6M, and ARM v7.
See also
Byte order, page 21, Byte order, page 210, --BE32, page 191, and --endian, page 170. Project>Options>General Options>Target>Endian mode
--BE32
Syntax Description
--BE32
191
Descriptions of options
This produces big-endian code and data. This is the only byte-addressing mode for all big-endian images prior to ARMv6. This mode is also available for ARM v6 with big-endian, but not for ARM v6M or ARM v7. See also Byte order, page 21, Byte order, page 210, --BE8, page 191, and --endian, page 170. Project>Options>General Options>Target>Endian mode
--config
Syntax Parameters
--config filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Use this option to specify the configuration file to be used by the linker (the default filename extension is icf). If no configuration file is specified, a default configuration is used. This option can only be used once on the command line. The chapter The linker configuration file. Project>Options>Linker>Config>Linker configuration file
Description
See also
--config_def
Syntax Parameters
symbol The name of the symbol to be used in the configuration file. By default, the value 0 (zero) is used. The constant value of the configuration symbol. --config_def symbol[=constant_value]
constant_value
Description
Use this option to define a constant configuration symbol to be used in the configuration file. This option has the same effect as the define symbol directive in the linker configuration file. This option can be used more that once on the command line. --define_symbol, page 193 and Interaction between ILINK and the application, page 56. Project>Options>Linker>Config>Defined symbols for configuration file
See also
192
Linker options
--cpp_init_routine
Syntax Parameters
routine A user-defined C++ dynamic initialization routine. --cpp_init_routine routine
Description
When using the IAR C/C++ compiler and the standard library, C++ dynamic initialization is handled automatically. In other cases you might need to use this option. If any sections with the section type INIT_ARRAY or PREINIT_ARRAY are included in your application, the C++ dynamic initialization routine is considered to be needed. By default, this routine is named __iar_cstart_call_ctors and is called by the startup code in the standard library. Use this option if you are not using the standard library and require another routine to handle these section types. To set this option, use Project>Options>Linker>Extra Options.
--cpu
Syntax Parameters
core Specifies a specific processor variant --cpu=core
Description
Use this option to select the processor variant for which the code is to be generated. The default is ARM7TDMI. --cpu, page 162 for a list of recognized cores and processor macrocells. Project>Options>General Options>Target>Processor configuration
See also
--define_symbol
Syntax Parameters
symbol The name of the constant symbol that can be used by the application. By default, the value 0 (zero) is used. The constant value of the symbol. --define_symbol symbol[=constant_value]
constant_value
193
Descriptions of options
Description
Use this option to define a constant symbol that can be used by your application. If no value is specified, 0 is used. This option can be used more than once on the command line. Note that his option is different from the define symbol directive. --config_def, page 192 and Interaction between ILINK and the application, page 56. Project>Options>Linker>#define>Defined symbols
See also
--diag_error
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117 --diag_error=tag[,tag,...]
Description
Use this option to reclassify certain diagnostic messages as errors. An error indicates a violation of the C or C++ language rules, of such severity that a violation of the linking rules of such severity that an executable image will not be generated. The exit code will be non-zero. This option may be used more than once on the command line. Project>Options>Linker>Diagnostics>Treat these as errors
--diag_remark
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe177 --diag_remark=tag[,tag,...]
Description
Use this option to reclassify certain diagnostic messages as remarks. A remark is the least severe type of diagnostic message and indicates a construction that may cause strange behavior in the executable image. This option may be used more than once on the command line.
194
Linker options
Note: By default, remarks are not displayed; use the --remarks option to display them. Project>Options>Linker>Diagnostics>Treat these as remarks
--diag_suppress
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117 --diag_suppress=tag[,tag,...]
Description
Use this option to suppress certain diagnostic messages. These messages will not be displayed. This option may be used more than once on the command line. Project>Options>Linker>Diagnostics>Suppress these diagnostics
--diag_warning
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe826 --diag_warning=tag[,tag,...]
Description
Use this option to reclassify certain diagnostic messages as warnings. A warning indicates an error or omission that is of concern, but which will not cause the linker to stop before linking is completed. This option may be used more than once on the command line. Project>Options>Linker>Diagnostics>Treat these as warnings
195
Descriptions of options
--diagnostics_tables
Syntax Parameters
--diagnostics_tables {filename|directory}
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. Use this option to list all possible diagnostic messages in a named file. This option cannot be given together with other options. This option is not available in the IDE.
Description
--entry
Syntax Parameters
symbol The name of the symbol to be treated as a root symbol and start label --entry symbol
Description
Use this option to make a symbol be treated as a root symbol and the start label of the application. This is useful for loaders. If this option is not used, the default start symbol is __iar_program_start. A root symbol is kept whether or not it is referenced from the rest of the application, provided its module is included. A module in an object file is always included and a module part of a library is only included if needed. Project>Options>Linker>Library>Override default program entry
--error_limit
Syntax Parameters
n The number of errors before the linker stops linking. n must be a positive integer; 0 indicates no limit. --error_limit=n
Description
Use the --error_limit option to specify the number of errors allowed before the linker stops the linking. By default, 100 errors are allowed. This option is not available in the IDE.
196
Linker options
--export_builtin_config
Syntax Parameters
--export_builtin_config filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Exports the configuration used by default to a file. This option is not available in the IDE.
Description
-f
Syntax Parameters
-f filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Use this option to make the linker read command line options from the named file, with the default filename extension xcl. In the command file, you format the items exactly as if they were on the command line itself, except that you may use multiple lines, because the newline character acts just as a space or tab character. Both C and C++ style comments are allowed in the file. Double quotes behave in the same way as in the Microsoft Windows command line environment. To set this option, use Project>Options>Linker>Extra Options.
Descriptions
--force_output
Syntax Description
--force_output
Use this option to produce an output executable image regardless of any linking errors. To set this option, use Project>Options>Linker>Extra Options
197
Descriptions of options
--image_input
Syntax Parameters
filename symbol section alignment The pure binary file containing the raw image you want to link The symbol which the binary data can be referenced with. The section where the binary data will be placed; default is .text. The alignment of the section; default is 1. --image_input filename [symbol,[section[,alignment]]]
Description
Use this option to link pure binary files in addition to the ordinary input files. The files entire contents are placed in the section, which means it can only contain pure binary data. The section where the contents of the filename file are placed, is only included if the symbol symbol is required by your application. Use the --keep option if you want to force a reference to the section.
Example
--image_input bootstrap.abs,Bootstrap,CSTARTUPCODE,4
The contents of the pure binary file bootstrap.abs are placed in the section CSTARTUPCODE. The section where the contents are placed is 4-byte aligned and will only be included if your application (or the command line option --keep) includes a reference to the symbol Bootstrap. See also --keep, page 198. Project>Options>Linker>Input>Raw binary image
--keep
Syntax Parameters
symbol The name of the symbol to be treated as a root symbol --keep symbol
Description
Normally, the linker keeps a symbol only if it is needed by your application. Use this option to make a symbol always be included in the final application. Project>Options>Linker>Input>Keep symbols
198
Linker options
--log
Syntax Parameters
initialization modules sections Log initialization decisions Log module selections Log section selections --log topic,topic,...
Description
Use this option to make the linker log information to stdout. The log information can be useful for understanding why an executable image became the way it is. --log_file, page 199. Project>Options>Linker>List>Generate log
See also
--log_file
Syntax Parameters
--log_file filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Use this option to direct the log output to the specified file. --log, page 199. Project>Options>Linker>List>Generate log
--mangled_names_in_messages
Syntax Descriptions
--mangled_names_in_messages
Use this option to produce both mangled and unmangled names for C/C++ symbols in messages. Mangling is a technique used for mapping a complex C name or a C++ name (for example, for overloading) into a simple name. For example, void h(int, char) becomes _Z1hic. This option is not available in the IDE.
199
Descriptions of options
--map
Syntax Description
--map {filename|directory}
Use this option to produce a linker memory map file. The map file has the default filename extension map. The map file contains:
Linking summary in the map file header which lists the version of the linker, the current date and time, and the command line that was used. Runtime attribute summary which lists AEABI attributes and IAR-specific runtime attributes. Placement summary which lists each section/block in address order, sorted by placement directives. Initialization table layout which lists the data ranges, packing methods, and compression ratios. Module summary which lists contributions from each module to the image, sorted by directory and library. Entry list which lists all public and some local symbols in alphabetical order, indicating which module they came from. Some of the bytes might be reported as shared. Shared objects are functions or data objects that are shared between modules. If any of these occur in more than one module, only one copy is retained. For example, in some cases inline functions are not inlined, which means that they are marked as shared, because only one instance of each function will be included in the final application. This mechanism is sometimes also used for compiler-generated code or data not directly associated with a particular function or variable, and when only one instance is required in the final application.
This option can only be used once on the command line. Project>Options>Linker>List>Generate linker map file
--no_fragments
Syntax Description
--no_fragments
Use this option to disable section fragment handling. Normally, the toolset uses IAR proprietary information for transferring section fragment information to the linker. The linker uses this information to remove unused code and data, and thus further minimize the size of the executable image.
200
Linker options
See also
Keeping symbols and sections, page 52. To set this option, use Project>Options>Linker>Extra Options
--no_library_search
Syntax Description
--no_library_search
Use this option to disable the automatic runtime library search. This option turns off the automatic inclusion of the correct standard libraries. This is useful, for example, if the application needs a user-built standard library, etc. Project>Options>Linker>Library>Automatic runtime library selection
--no_locals
Syntax Description
--no_locals
Use this option to remove local symbols from the ELF executable image. Note: This option does not remove any local symbols from the DWARF information in the executable image. Project>Options>Linker>Output
--no_remove
Syntax Description
--no_remove
When this option is used, unused sections are not removed. In other words, each module that is included in the executable image contains all its original sections. Keeping symbols and sections, page 52. To set this option, use Project>Options>Linker>Extra Options
See also
201
Descriptions of options
--no_veneers
Syntax Description
--no_veneers
Use this option to disable the insertion of veneers even though the executable image needs it. In this case, the linker will generate a relocation error for each reference that needs a veneer. Veneers, page 57. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
See also
--no_warnings
Syntax Description
--no_warnings
By default, the linker issues warning messages. Use this option to disable all warning messages. This option is not available in the IDE.
--no_wrap_diagnostics
Syntax Description
--no_wrap_diagnostics
By default, long lines in diagnostic messages are broken into several lines to make the message easier to read. Use this option to disable line wrapping of diagnostic messages. This option is not available in the IDE.
-o, --output
Syntax
-o {filename|directory} --output {filename|directory}
Parameters
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156.
202
Linker options
Description
By default, the object executable image produced by the linker is located in a file with the name a.out. Use this option to explicitly specify a different output filename, which by default will have the filename extension out. Project>Options>Linker>Output>Output file
--only_stdout
Syntax Description
--only_stdout
Use this option to make the linker use the standard output stream (stdout) also for messages that are normally directed to the error output stream (stderr). This option is not available in the IDE.
--ose_load_module
Syntax Description
--ose_load_module
By default, the linker generates a ROMable executable image. Use this option to generate an executable image in the OSE load module image format instead. Project>Options>Linker>Output
--output, -o
Syntax
--output {filename|directory} -o {filename|directory}
Parameters
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. By default, the object executable image produced by the linker is located in a file with the name a.out. Use this option to explicitly specify a different output filename, which by default will have the filename extension out. Project>Options>Linker>Output>Output file
Description
203
Descriptions of options
--pi_veneers
Syntax Description
--pi_veneers
Use this option to make the linker generate position-independent veneers. Note that this type of veneers is bigger and slower than normal veneers. Veneers, page 57. To set this option, use Project>Options>C/C++ Compiler>Extra Options.
See also
--place_holder
Syntax Parameters
symbol size section alignment The name of the symbol to create Size in ROM; by default 4 bytes Section name to use; by default .text Alignment of section; by default 1 --place_holder symbol[,size[,section[,alignment]]]
Description
Use this option to reserve a place in ROM to be filled by some other tool, for example a checksum calculated by ielftool. Each use of this linker option results in a section with the specified name, size, and alignment. The symbol can be used by your application to refer to the section. Note: Like any other section, sections created by the --place_holder option will only be included in your application if the section appears to be needed. The --keep linker option, or the keep linker directive can be used for forcing such section to be included.
See also
IAR utilities, page 323. To set this option, use Project>Options>Linker>Extra Options
204
Linker options
--redirect
Syntax Parameters
from_symbol to_symbol The name of the source symbol The name of the destination symbol --redirect from_symbol=to_symbol
Description
Use this option to change a reference from one symbol to another symbol. To set this option, use Project>Options>Linker>Extra Options
--remarks
Syntax Description
--remarks
The least severe diagnostic messages are called remarks. A remark indicates a source code construct that may cause strange behavior in the generated code. By default, the linker does not generate remarks. Use this option to make the linker generate remarks. Severity levels, page 153. Project>Options>Linker>Diagnostics>Enable remarks
See also
--semihosting
Syntax Parameters
iar_breakpoint The IAR-specific mechanism can be used when debugging applications that use SWI/SVC extensively. --semihosting[=iar_breakpoint]
Description
Use this option to include the debug interfacebreakpoint mechanismin the output image. If no parameter is specified, the SWI/SVC mechanism is included for ARM7/9/11, and the BKPT mechanism is included for Cortex-M. Low-level interface for debug support, page 64. Project>Options>General Options>Library Configuration>Semihosted
See also
205
Descriptions of options
--silent
Syntax Description
--silent
By default, the linker issues introductory messages and a final statistics report. Use this option to make the linker operate without sending these messages to the standard output stream (normally the screen). This option does not affect the display of error and warning messages. This option is not available in the IDE.
--strip
Syntax Description
--strip
By default, the linker retains the debug information from the input object files in the output executable image. Use this option to remove that information. To set related options, choose: Project>Options>Linker>Output>Include debug information in output
--warnings_affect_exit_code
Syntax Description
--warnings_affect_exit_code
By default, the exit code is not affected by warnings, because only errors produce a non-zero exit code. With this option, warnings will also generate a non-zero exit code. This option is not available in the IDE.
--warnings_are_errors
Syntax Description
--warnings_are_errors
Use this option to make the linker treat all warnings as errors. If the linker encounters an error, no executable image is generated. Warnings that have been changed into remarks are not treated as errors.
206
Linker options
Note: Any diagnostic messages that have been reclassified as warnings by the option --diag_warning directive will also be treated as errors when --warnings_are_errors is used. See also --diag_warning, page 195 and --diag_warning, page 167. Project>Options>Linker>Diagnostics>Treat all warnings as errors
207
Descriptions of options
208
Data representation
This chapter describes the data types, pointers, and structure types supported by the compiler. See the chapter Efficient coding for embedded applications for information about which data types and pointers provide the most efficient code for your application.
Alignment
Every C data object has an alignment that controls how the object can be stored in memory. Should an object have an alignment of, for example, 4, it must be stored on an address that is divisible by 4. The reason for the concept of alignment is that some processors have hardware limitations for how the memory can be accessed. Assume that a processor can read 4 bytes of memory using one instruction, but only when the memory read is placed on an address divisible by 4. Then, 4-byte objects, such as long integers, will have alignment 4. Another processor might only be able to read 2 bytes at a time; in that environment, the alignment for a 4-byte long integer might be 2. A structure type will have the same alignment as the structure member with the most strict alignment. To decrease the alignment requirements on the structure and its members, use #pragma pack or the __packed data type attribute. All data types must have a size that is a multiple of their alignment. Otherwise, only the first element of an array would be guaranteed to be placed in accordance with the alignment requirements. This means that the compiler might add pad bytes at the end of the structure. For more information about pad bytes, see Packed structure types, page 217. Note that with the #pragma data_alignment directive you can increase the alignment demands on specific variables.
209
Byte order
Objects with alignment 4 must be stored at an address divisible by 4, while objects with alignment 2 must be stored at addresses divisible by 2. The compiler ensures this by assigning an alignment to every data type, ensuring that the ARM core will be able to read the data.
Byte order
The ARM core stores data in either little-endian or big-endian byte order. To specify the byte order, use the --endian compiler option; see --endian, page 170. In the little-endian byte order, which is default, the least significant byte is stored at the lowest address in memory. The most significant byte is stored at the highest address. In the big-endian byte order, the most significant byte is stored at the lowest address in memory. The least significant byte is stored at the highest address. If you use the big-endian byte order, it might be necessary to use the #pragma bitfields=reversed directive to be compatible with code for other compilers and I/O register definitions of some devices, see Bitfields, page 212. Note: There are two variants of the big-endian mode, BE8 and BE32, which you specify at link time. In BE8 data is big-endian and code is little-endian. In BE32 both data and code are big-endian. In architectures before v6, the BE32 endian mode is used, and after v6 the BE8 mode is used. In the v6 (ARM11) architecture, both big-endian modes are supported.
INTEGER TYPES
This table gives the size and range of each integer data type:
Data type Size Range Alignment
bool char signed char unsigned char signed short unsigned short
Table 25: Integer types
1 1 1 1 2 2
210
Data representation
Data type
Size
Range
Alignment
signed int unsigned int signed long unsigned long signed long long unsigned long long
4 4 4 4 8 8
Bool
The bool data type is supported by default in the C++ language. If you have enabled language extensions, the bool type can also be used in C source code if you include the file stdbool.h. This will also enable the boolean values false and true.
211
The wchar_t data type is supported by default in the C++ language. To use the wchar_t type also in C source code, you must include the file stddef.h from the runtime library.
Bitfields
In ISO/ANSI C, int, signed int, and unsigned int can be used as the base type for integer bitfields. It is implementation defined whether the type specified by int is the same as signed int or unsigned int. In the IAR C/C++ Compiler for ARM, bitfields specified as int are treated as unsigned int. Furthermore, any integer type can be used as the base type when language extensions are enabled. Bitfields in expressions will have the same data type as the integer base type. The compiler places bitfield members based on the byte order mode that is used. By default in little-endian mode, the compiler places bitfield members from the least significant to the most significant bit in the container type. And by default in big-endian mode, the compiler places bitfield members from the most significant to the least significant bit in the container type. A bitfield is assigned to the last available container of its base type which has enough unassigned bits to contain the entire bitfield. This means that bitfield containers can overlap other structure members as long as the order of the fields in the structure is preserved, for example in big-endian mode:
struct example { char a; short b : 10; int c : 6; };
Here the first declaration creates an unsigned character which is allocated to bits 24 through 31. The second declaration creates a signed short integer member of size 10 bits. This member is allocated to bits 15 through 6 as it will not fit in the remaining 8 bits of the first short integer container. The last bitfield member declared is placed in the bits 0 through 5. If seen as a 32-bit value, the structure looks like this in memory:
212
Data representation
Use the directive #pragma bitfields=disjoint_types to force the bitfield containers to be disjoint, or in other words, not to overlap. The layout of the above example structure would then become:
Use the directive #pragma bitfields=reversed_disjoint_types to place the bitfield members from the least significant bit to the most significant bit in non-overlapping storage containers.
FLOATING-POINT TYPES
In the IAR C/C++ Compiler for ARM, floating-point values are represented in standard IEEE 754 format. The sizes for the different floating-point types are:
Type Size Range (+/-) Decimals Exponent Mantissa
7 15 15
For Cortex-M0 and Cortex-M1, the compiler does not support subnormal numbers. All operations that should produce subnormal numbers will instead generate zero. For information about the representation of subnormal numbers for other cores, see Representation of special floating-point numbers, page 214. Exception flags according to the IEEE 754 standard are not supported. The alignment for the float type is 4, and for the long double type it is 8.
213
The precision of the float operators (+, -, *, and /) is approximately 7 decimal digits.
The exponent is 11 bits, and the mantissa is 52 bits. The value of the number is:
(-1)S * 2(Exponent-1023) * 1.Mantissa
The precision of the float operators (+, -, *, and /) is approximately 15 decimal digits.
Zero is represented by zero mantissa and exponent. The sign bit signifies positive or negative zero. Infinity is represented by setting the exponent to the highest value and the mantissa to zero. The sign bit signifies positive or negative infinity. Not a number (NaN) is represented by setting the exponent to the highest positive value and at least one bit set in the 20 most significant bits of the mantissa. Remaining bits are zero. Subnormal numbers are used for representing values smaller than what can be represented by normal values. The drawback is that the precision will decrease with smaller values. The exponent is set to 0 to signify that the number is denormalized, even though the number is treated as if the exponent was 1. Unlike normal numbers, denormalized numbers do not have an implicit 1 as the most significant bit (the MSB) of the mantissa. The value of a denormalized number is:
(-1)S * 2(1-BIAS) * 0.Mantissa
214
Data representation
where BIAS is 127 and 1023 for 32-bit and 64-bit floating-point values, respectively.
Pointer types
The compiler has two basic types of pointers: function pointers and data pointers.
FUNCTION POINTERS
The size of function pointers is always 32 bits and the range is 0x00xFFFFFFFF. When function pointer types are declared, attributes are inserted before the * sign, for example:
typedef void (__thumb __interwork * IntHandler) (void);
DATA POINTERS
There is one data pointer available. Its size is 32 bits and the range is 0x00xFFFFFFFF.
CASTING
Casts between pointers have these characteristics:
Casting a value of an integer type to a pointer of a smaller type is performed by truncation Casting a value of an unsigned integer type to a pointer of a larger type is performed by zero extension Casting a value of a signed integer type to a pointer of a larger type is performed by sign extension Casting a pointer type to a smaller integer type is performed by truncation Casting a pointer type to a larger integer type is performed by zero extension Casting a data pointer to a function pointer and vice versa is illegal Casting a function pointer to an integer type gives an undefined result
size_t
size_t is the unsigned integer type required to hold the maximum size of an object. In the IAR C/C++ Compiler for ARM, the size of size_t is 32 bits.
215
Structure types
ptrdiff_t
ptrdiff_t is the type of the signed integer required to hold the difference between two
pointers to elements of the same array. In the IAR C/C++ Compiler for ARM, the size of ptrdiff_t is 32 bits.
intptr_t
intptr_t is a signed integer type large enough to contain a void *. In the IAR C/C++ Compiler for ARM, the size of intptr_t is 32 bits.
uintptr_t
uintptr_t is equivalent to intptr_t, with the exception that it is unsigned.
Structure types
The members of a struct are stored sequentially in the order in which they are declared: the first member has the lowest memory address.
ALIGNMENT
The struct and union types have the same alignment as the member with the highest alignment requirement. The size of a struct is also adjusted to allow arrays of aligned structure objects.
GENERAL LAYOUT
Members of a struct are always allocated in the order specified in the declaration. Each member is placed in the struct according to the specified alignment (offsets). Example
struct First { char c; short s; } s;
216
Data representation
The alignment of the structure is 2 bytes, and a pad byte must be inserted to give short s the correct alignment.
This example declares a new non-packed structure, S2, that contains the structure s declared in the previous example:
struct S2 { struct S s; long l; };
217
Type qualifiers
The structure S will use the memory layout, size, and alignment described in the previous example. The alignment of the member l is 4, which means that alignment of the structure S2 will become 2. For more information, see Alignment of elements in a structure, page 129.
Type qualifiers
According to the ISO/ANSI C standard, volatile and const are type qualifiers.
Shared access; the object is shared between several tasks in a multitasking environment Trigger access; as for a memory-mapped SFR where the fact that an access occurs has an effect Modified access; where the contents of the object can change in ways not known to the compiler.
Considers each read and write access to an object declared volatile as an access The unit for the access is either the entire object or, for accesses to an element in a composite objectsuch as an array, struct, class, or unionthe element. For example:
char volatile a; a = 5; /* A write access */ a += 6; /* First a read then a write access */
218
Data representation
However, these rules are not detailed enough to handle the hardware-related requirements. The rules specific to the IAR C/C++ Compiler for ARM are described below.
All accesses are preserved All accesses are complete, that is, the whole object is accessed All accesses are performed in the same order as given in the abstract machine All accesses are atomic, that is, they cannot be interrupted.
The compiler adheres to these rules for accesses to all 8-, 16-, and 32-bit scalar types, except for accesses to unaligned 16- and 32-bit fields in packed structures. For all other object types, only the rule that states that all accesses are preserved applies.
219
220
Compiler extensions
This chapter gives a brief overview of the compiler extensions to the ISO/ANSI C standard. All extensions can also be used for the C++ programming language. More specifically the chapter describes the available C language extensions.
C/C++ language extensions For a summary of available language extensions, see C language extensions, page 222. For reference information about the extended keywords, see the chapter Extended keywords. For information about C++, the two levels of support for the language, and C++ language extensions; see the chapter Using C++.
Pragma directives The #pragma directive is defined by the ISO/ANSI C standard and is a mechanism for using vendor-specific extensions in a controlled way to make sure that the source code is still portable. The compiler provides a set of predefined pragma directives, which can be used for controlling the behavior of the compiler, for example how it allocates memory, whether it allows extended keywords, and whether it outputs warning messages. Most pragma directives are preprocessed, which means that macros are substituted in a pragma directive. The pragma directives are always enabled in the compiler. For several of them there is also a corresponding C/C++ language extension. For a list of available pragma directives, see the chapter Pragma directives.
Preprocessor extensions The preprocessor of the compiler adheres to the ISO/ANSI standard. The compiler also makes several preprocessor-related extensions available to you. For more information, see the chapter The preprocessor.
Intrinsic functions The intrinsic functions provide direct access to low-level processor operations and can be very useful in, for example, time-critical routines. The intrinsic functions compile into inline code, either as a single instruction or as a short sequence of
221
C language extensions
instructions. To read more about using intrinsic functions, see Mixing C and assembler, page 91. For a list of available functions, see the chapter Intrinsic functions.
Library functions The IAR DLIB Library provides most of the important C and C++ library definitions that apply to embedded systems. The library also provides some extensions, partly taken from the C99 standard. For more information, see IAR DLIB Library, page 290.
Note: Any use of these extensions, except for the pragma directives, makes your application inconsistent with the ISO/ANSI C standard.
C language extensions
This section gives a brief overview of the C language extensions available in the compiler. The compiler provides a wide set of extensions, so to help you to find the extensions required by your application, the extensions are grouped according to their expected usefulness. In short, this means:
Important language extensionsextensions specifically tailored for efficient embedded programming, typically to meet memory restrictions Useful language extensionsfeatures considered useful and typically taken from related standards, such as C99 and C++ Minor language extensions, that is, the relaxation of some minor standards issues and also some useful but minor syntax extensions.
Type attributes, and object attributes For information about the related concepts, the general syntax rules, and for reference information, see the chapter Extended keywords.
Placement at an absolute address or in a named section The @ operator or the directive #pragma location can be used for placing global and static variables at absolute addresses, or placing a variable or function in a named
222
Compiler extensions
section. For more information about using these primitives, see Controlling data and function placement in memory, page 131, and location, page 251.
Alignment Each data type has its own alignment, for more details, see Alignment, page 209. If you want to change the alignment, the __packed data type attribute, and the #pragma pack and #pragma data_alignment directives are available. If you want to use the alignment of an object, use the __ALIGNOF__() operator. The __ALIGNOF__ operator is used for accessing the alignment of an object. It takes one of two forms:
Anonymous structs and unions C++ includes a feature named anonymous unions. The compiler allows a similar feature for both structs and unions in the C programming language. For more information, see Anonymous structs and unions, page 129.
Bitfields and non-standard types In ISO/ANSI C, a bitfield must be of type int or unsigned int. Using IAR Systems language extensions, any integer type or enumeration can be used. The advantage is that the struct will sometimes be smaller. This matches G.5.8 in the appendix of the ISO standard, ISO Portability Issues. For more information, see Bitfields, page 212.
These operators can be used on named sections or on named blocks defined in the linker configuration file. The __section_begin operator returns the address of the first byte of the named section or block. The __section_end operator returns the address of the first byte after the named section or block. The __section_size operator returns the size of the named section or block in bytes.
223
C language extensions
Note: The aliases __segment_begin/__sfb, __segment_end/__sfe, and __segment_size/__sfs can also be used. When using the @ operator or the #pragma location directive to place a data object or a function in a user-defined section, or when using named blocks in the linker configuration file, the section operators can be used for getting the start and end of the memory range where the sections or blocks were placed. The named section must be a string literal and section must have been declared earlier with the #pragma section directive. The type of the __section_begin operator is a pointer to void. Note that you must enable language extensions to use these operators. The operators are implemented in terms of symbols with dedicated names, and will appear in the linker map file under these names:
.
Operator
Symbol
Note that the linker will not necessarily place sections with the same name contiguously when these operators are not used. Using one of these operators (or the equivalent symbols) will cause the linker to behave as if the sections were in a named block. This is to assure that the sections are placed contiguously, so that the operators can be assigned meaningful values. If this is in conflict with the section placement as specified in the linker configuration file, the linker will issue an error. Example In this example, the type of the __section_begin operator is void *.
#pragma section="MYSECTION" ... section_start_address = __section_begin("MYSECTION");
224
Compiler extensions
Inline functions The #pragma inline directive, alternatively the inline keyword, advises the compiler that the function whose declaration follows immediately after the directive should be inlined. This is similar to the C++ keyword inline. For more information, see inline, page 250.
Mixing declarations and statements It is possible to mix declarations and statements within the same scope. This feature is part of the C99 standard and C++.
Declaration in for loops It is possible to have a declaration in the initialization expression of a for loop, for example:
for (int i = 0; i < 10; ++i) { /* Do something here. */ }
The bool data type To use the bool type in C source code, you must include the file stdbool.h. This feature is part of the C99 standard and C++. (The bool data type is supported by default in C++.)
C++ style comments C++ style comments are accepted. A C++ style comment starts with the character sequence // and continues to the end of the line. For example:
// The length of the bar, in centimeters. int length;
Inline assembler
Inline assembler can be used for inserting assembler instructions in the generated function. This feature is part of the C99 standard and C++. The asm and __asm extended keywords both insert an assembler instruction. However, when compiling C source code, the asm keyword is not available when the option --strict_ansi is used. The __asm keyword is always available. Note: Not all assembler directives or operators can be inserted using this keyword. The syntax is:
asm ("string");
225
C language extensions
The string can be a valid assembler instruction or a data definition assembler directive, but not a comment. You can write several consecutive inline assembler instructions, for example:
asm ("Label: " nop\n" b Label");
where \n (new line) separates each new assembler instruction. Note that you can define and use local labels in inline assembler instructions. For more information about inline assembler, see Mixing C and assembler, page 91.
Compound literals
To create compound literals you can use this syntax:
/* Create a pointer to an anonymous array */ int *p = (int []) {1, 2, 3}; /* Create a pointer to an anonymous structX */ structX *px = &(structX) {5, 6, 7};
Note:
A compound literal can be modified unless it is declared const Compound literals are not supported in Embedded C++ and Extended EC++. This feature is part of the C99 standard.
226
Compiler extensions
struct str * GetAStr(int size) { return malloc(sizeof(struct str) + sizeof(unsigned long) * size); } void UseStr(struct str * s) { s->b[10] = 0; }
The incomplete array will be aligned in the structure just like any other member of the structure. For more information about structure alignment, see Structure types, page 216.
227
C language extensions
Examples This definition shows a struct and its initialization using designators:
struct { int i; int j; int k; int l; short array[10]; } u = { .l = 6, .j = 6, 8, .array[7] = 2, .array[3] = 2, 5, .k = 4 };
/* /* /* /* /* /* /*
Note that a designator specifies the destination element of the initialization. Note also that if one element is initialized more than once, it is the last initialization that will be used. To initialize an element in a union other than the first, do like this:
union { int i; float f; } y = {.f = 5.0};
To set the size of an array by initializing the last element, do like this:
char array[] = {[10] = 'a'};
Arrays of incomplete types An array can have an incomplete struct, union, or enum type as its element type. The types must be completed before the array is used (if it is), or by the end of the compilation unit (if it is not).
228
Compiler extensions
Forward declaration of enum types The IAR Systems language extensions allow that you first declare the name of an enum and later resolve it by specifying the brace-enclosed list.
Missing semicolon at end of struct or union specifier A warning is issued if the semicolon at the end of a struct or union specifier is missing.
Null and void In operations on pointers, a pointer to void is always implicitly converted to another type if necessary, and a null pointer constant is always implicitly converted to a null pointer of the right type if necessary. In ISO/ANSI C, some operators allow such things, while others do not allow them.
Casting pointers to integers in static initializers In an initializer, a pointer constant value can be cast to an integral type if the integral type is large enough to contain it. For more information about casting pointers, see Casting, page 215.
Taking the address of a register variable In ISO/ANSI C, it is illegal to take the address of a variable specified as a register variable. The compiler allows this, but a warning is issued.
Duplicated size and sign specifiers Should the size or sign specifiers be duplicated (for example, short short or unsigned unsigned), an error is issued.
Repeated typedef declarations Redeclarations of typedef that occur in the same scope are allowed, but a warning is issued.
Mixing pointer types Assignment and pointer difference is allowed between pointers to types that are interchangeable but not identical; for example, unsigned char * and char *. This includes pointers to integral types of the same size. A warning is issued. Assignment of a string constant to a pointer to any kind of character is allowed, and no warning is issued.
Non-top level const Assignment of pointers is allowed in cases where the destination type has added type qualifiers that are not at the top level (for example, int ** to int const **). Comparing and taking the difference of such pointers is also allowed.
229
C language extensions
Non-lvalue arrays A non-lvalue array expression is converted to a pointer to the first element of the array when it is used.
Comments at the end of preprocessor directives This extension, which makes it legal to place text after preprocessor directives, is enabled, unless strict ISO/ANSI mode is used. The purpose of this language extension is to support compilation of legacy code; we do not recommend that you write new code in this fashion.
An extra comma at the end of enum lists Placing an extra comma is allowed at the end of an enum list. In strict ISO/ANSI mode, a warning is issued.
A label preceding a } In ISO/ANSI C, a label must be followed by at least one statement. Therefore, it is illegal to place the label at the end of a block. The compiler issues a warning.
Empty declarations An empty declaration (a semicolon by itself) is allowed, but a remark is issued (provided that remarks are enabled).
Single-value initialization ISO/ANSI C requires that all initializer expressions of static arrays, structs, and unions are enclosed in braces. Single-value initializers are allowed to appear without braces, but a warning is issued. The compiler accepts this expression:
struct str { int a; } x = 10;
230
Compiler extensions
Declarations in other scopes External and static declarations in other scopes are visible. In the following example, the variable y can be used at the end of the function, even though it should only be visible in the body of the if statement. A warning is issued.
int test(int x) { if (x) { extern int y; y = 1; } return y; }
Expanding function names into strings with the function as context Use any of the symbols __func__ or __FUNCTION__ inside a function body to make the symbol expand into a string, with the function name as context. Use the symbol __PRETTY_FUNCTION__ to also include the parameter types and return type. The result might, for example, look like this if you use the __PRETTY_FUNCTION__ symbol:
"void func(char)"
These symbols are useful for assertions and other trace utilities and they require that language extensions are enabled, see -e, page 169.
231
C language extensions
232
Extended keywords
This chapter describes the extended keywords that support specific features of the ARM core and the general syntax rules for the keywords. Finally the chapter gives a detailed description of each keyword.
Type attributes affect the external functionality of the data object or function Object attributes affect the internal functionality of the data object or function.
The syntax for the keywords differs slightly depending on whether it is a type attribute or an object attribute, and whether it is applied to a data object or a function. For detailed information about each attribute, see Descriptions of extended keywords, page 237. Note: The extended keywords are only available when language extensions are enabled in the compiler. In the IDE, language extensions are enabled by default. Use the -e compiler option to enable language extensions. See -e, page 169 for additional information.
TYPE ATTRIBUTES
Type attributes define how a function is called, or how a data object is accessed. This means that if you use a type attribute, it must be specified both when a function or data object is defined and when it is declared. You can either place the type attributes directly in your source code, or use the pragma directive #pragma type_attribute. These general type attributes are available:
Function type attributes affect how the function should be called: __arm, __fiq, __interwork, __irq, __swi, __task, and __thumb
233
You can specify as many type attributes as required for each level of pointer indirection. To read more about the type qualifiers const and volatile, see Type qualifiers, page 218.
Note that the attribute affects both identifiers. This declaration of i and j is equivalent with the previous one:
#pragma type_attribute=__little_endian int i, j;
The advantage of using pragma directives for specifying keywords is that it offers you a method to make sure that the source code is portable.
or
234
Extended keywords
OBJECT ATTRIBUTES
Object attributes affect the internal functionality of functions and data objects, but not how the function is called or how the data is accessed. This means that an object attribute does not need to be present in the declaration of an object. These object attributes are available:
Object attributes that can be used for variables: __no_init Object attributes that can be used for functions and variables: location, @, __root, and __weak, Object attributes that can be used for functions: __intrinsic, __nested, __noreturn, and __ramfunc.
You can specify as many object attributes as required for a specific function or data object. For more information about location and @, see Controlling data and function placement in memory, page 131.
The #pragma object_attribute directive can also be used. This declaration is equivalent to the previous one:
#pragma object_attribute=__no_init int myarray[10];
Note: Object attributes cannot be used in combination with the typedef keyword.
235
__arm __big_endian __fiq __interwork __intrinsic __irq __little_endian __nested __no_init __noreturn __packed __ramfunc __root __swi __task __thumb __weak
Table 28: Extended keywords summary
Makes a function execute in ARM mode Declares a variable to use the big endian byte order Declares a fast interrupt function Declares a function to be callable from both ARM and Thumb mode Reserved for compiler internal use only Declares an interrupt function Declares a variable to use the little endian byte order Allows an __irq declared interrupt function to be nested, that is, interruptible by the same type of interrupt Supports non-volatile memory Informs the compiler that the function will not return Decreases data type alignment to 1 Makes a function execute in RAM Ensures that a function or variable is included in the object code even if unused Declares a software interrupt function Relaxes the rules for preserving registers Makes a function execute in Thumb mode Declares a symbol to be externally weakly linked
236
Extended keywords
__arm
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. The __arm keyword makes a function execute in ARM mode. An __arm declared function can, unless it is also declared __interwork, only be called from functions that also execute in ARM mode. A function declared __arm cannot be declared __thumb. Note: Non-interwork ARM functions cannot be called from Thumb mode. Example See also
__arm int func1(void);
Description
__big_endian
Syntax Follows the generic syntax rules for type attributes that can be used on data objects, see Type attributes, page 233. The __big_endian keyword is used for accessing a variable that is stored in the big-endian byte order regardless of what byte order the rest of the application uses. The __big_endian keyword is available when you compile for ARMv6 or higher.
__big_endian long my_variable;
Description
__fiq
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. The __fiq keyword declares a fast interrupt function. All interrupt functions must be compiled in ARM mode. A function declared __fiq does not accept parameters and does not have a return value.
Description
237
Example
__interwork
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. A function declared __interwork can be called from functions executing in either ARM or Thumb mode. Note: By default, functions are interwork when the --interwork compiler option is used, and when the --cpu option is used and it specifies a core where interwork is default. Example
typedef void (__thumb __interwork *IntHandler)(void);
Description
__intrinsic
Description The __intrinsic keyword is reserved for compiler internal use only.
__irq
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. The __irq keyword declares an interrupt function. All interrupt functions must be compiled in ARM mode. A function declared __irq does not accept parameters and does not have a return value.
__irq __arm void interrupt_function(void);
Description
Example
__little_endian
Syntax Follows the generic syntax rules for type attributes that can be used on data objects, see Type attributes, page 233. The __little_endian keyword is used for accessing a variable that is stored in the little-endian byte order regardless of what byte order the rest of the application uses. The __little_endian keyword is available when you compile for ARMv6 or higher.
__little_endian long my_variable;
Description
Example
238
Extended keywords
See also
__nested
Syntax Follows the generic syntax rules for object attributes that can be used on functions, see Object attributes, page 235. The __nested keyword modifies the enter and exit code of an interrupt function to allow for nested interrupts. This allows interrupts to be enabled, which means new interrupts can be served inside an interrupt function, without overwriting the SPSR and return address in R14. Nested interrupts are only supported for __irq declared functions. Note: The __nested keyword requires the processor mode to be in either User or System mode. Example See also
__irq __nested __arm void interrupt_handler(void);
Description
__no_init
Syntax Description Follows the generic syntax rules for object attributes, see Object attributes, page 235. Use the __no_init keyword to place a data object in non-volatile memory. This means that the initialization of the variable, for example at system startup, is suppressed.
__no_init int myarray[10];
__noreturn
Syntax Description Follows the generic syntax rules for object attributes, see Object attributes, page 235. The __noreturn keyword can be used on a function to inform the compiler that the function will not return. If you use this keyword on such functions, the compiler can optimize more efficiently. Examples of functions that do not return are abort and exit.
__noreturn void terminate(void);
Example
239
__packed
Syntax Follows the generic syntax rules for type attributes that can be used on data, see Type attributes, page 233. Use the __packed keyword to decrease the data type alignment to 1. __packed can be used for two purposes:
Description
When used with a struct or union type definition, the maximum alignment of members of that struct or union is set to 1, to eliminate any gaps between the members. The type of each members also receives the __packed type attribute. When used with any other type, the resulting type is the same as the type without the __packed type attribute, but with an alignment of 1. Types that already have an alignment of 1 are not affected by the __packed type attribute.
A normal pointer can be implicitly converted to a pointer to __packed, but the reverse conversion requires a cast. Note: Accessing data types at other alignments than their natural alignment can result in code that is significantly larger and slower. Example
__packed struct X {char ch; int i;}; /* No pad bytes void foo (struct X * xp) /* No need for __packed here { int * p1 = &xp->1;/* Error:"int *">"int __packed *" int __packed * p2 = &xp->i; /* OK char * p2 = &xp->ch; /* OK, char not affected } */ */ */ */ */
See also
__ramfunc
Syntax Description Follows the generic syntax rules for object attributes, see Object attributes, page 235. The __ramfunc keyword makes a function execute in RAM. Two code sections will be created: one for the RAM execution, and one for the ROM initialization. If a function declared __ramfunc tries to access ROM, the compiler will issue a warning. This behavior is intended to simplify the creation of upgrade routines, for instance, rewriting parts of flash memory. If this is not why you have declared the function __ramfunc, you may safely ignore or disable these warnings. Functions declared __ramfunc are by default stored in the section named CODE_I.
240
Extended keywords
To read more about __ramfunc declared functions in relation to breakpoints, see the IAR Embedded Workbench IDE User Guide for ARM.
__root
Syntax Description Follows the generic syntax rules for object attributes, see Object attributes, page 235. A function or variable with the __root attribute is kept whether or not it is referenced from the rest of the application, provided its module is included. Program modules are always included and library modules are only included if needed.
__root int myarray[10];
To read more about root symbols and how they are kept, see the .
__swi
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. The __swi keyword declares a software interrupt function. It inserts an SVC (formerly SWI) instruction and the specified software interrupt number to make a proper function call. A function declared __swi accepts arguments and returns values. The __swi keyword makes the compiler generate the correct return sequence for a specific software interrupt function. Software interrupt functions follow the same calling convention regarding parameters and return values as an ordinary function, except for the stack usage. The __swi keyword also expects a software interrupt number which is specified with the #pragma swi_number=number directive. The swi_number is used as an argument to the generated assembler SWC instruction, and can be used by the SVC interrupt handler, for example SWI_Handler, to select one software interrupt function in a system containing several such functions. Note that the software interrupt number should only be specified in the function declarationtypically, in a header file that you include in the source code file that calls the interrupt functionnot in the function definition. Note: All interrupt functions must be compiled in ARM mode, except for Cortex-M. Use either the __arm keyword or the #pragma type_attribute=__arm directive to alter the default behavior if needed.
Description
241
Example
To declare your software interrupt function, typically in a header file, write for example like this:
#pragma swi_number=0x23 __swi int swi0x23_function(int a, int b); ...
...
Somewhere in your application source code, you define your software interrupt function:
... __swi __arm int the_actual_swi0x23_function(int a, int b) { ... return 42; }
See also
__task
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. This keyword allows functions to relax the rules for preserving registers. Typically, the keyword is used on the start function for a task in an RTOS. By default, functions save the contents of used preserved registers on the stack upon entry, and restore them at exit. Functions that are declared __task do not save all registers, and therefore require less stack space. Because a function declared __task can corrupt registers that are needed by the calling function, you should only use __task on functions that do not return or call such a function from assembler code. The function main can be declared __task, unless it is explicitly called from the application. In real-time applications with more than one task, the root function of each task can be declared __task.
Description
242
Extended keywords
Example
__thumb
Syntax Follows the generic syntax rules for type attributes that can be used on functions, see Type attributes, page 233. The __thumb keyword makes a function execute in Thumb mode. Unless the function is also declared __interwork, the function declared __thumb can only be called from functions that also execute in Thumb mode. A function declared __thumb cannot be declared __arm. Note: Non-interwork Thumb functions cannot be called from ARM mode. Example See also
__thumb int func2(void);
Description
__weak
Syntax Description Follows the generic syntax rules for object attributes, see Object attributes, page 235. Using the __weak object attribute on an external declaration of a symbol makes all references to that symbol in the module weak. Using the __weak object attribute on a public definition of a symbol makes that definition a weak definition. The linker will not include a module from a library solely to satisfy weak references to a symbol, nor will the lack of a definition for a weak reference result in an error. If no definition is included, the address of the object will be zero. When linking, a symbol can have any number of weak definitions, and at most one non-weak definition. If the symbol is needed, and there is a non-weak definition, this definition will be used. If there is no non-weak definition, one of the weak definitions will be used. Example
extern __weak int foo; /* A weak reference */ __weak void bar(void); /* A weak definition */ { /* Increment foo if it was included */ if (&foo != 0) ++foo;
243
244
Pragma directives
This chapter describes the pragma directives of the compiler. The #pragma directive is defined by the ISO/ANSI C standard and is a mechanism for using vendor-specific extensions in a controlled way to make sure that the source code is still portable. The pragma directives control the behavior of the compiler, for example how it allocates memory for variables and functions, whether it allows extended keywords, and whether it outputs warning messages. The pragma directives are always enabled in the compiler.
bitfields data_alignment diag_default diag_error diag_remark diag_suppress diag_warning include_alias inline language location message object_attribute optimize
Table 29: Pragma directives summary
Controls the order of bitfield members Gives a variable a higher (more strict) alignment Changes the severity level of diagnostic messages Changes the severity level of diagnostic messages Changes the severity level of diagnostic messages Suppresses diagnostic messages Changes the severity level of diagnostic messages Specifies an alias for an include file Inlines a function Controls the IAR Systems language extensions Specifies the absolute address of a variable, or places groups of functions or variables in named sections Prints a message Changes the definition of a variable or a function Specifies the type and level of an optimization
245
Pragma directive
Description
Specifies the alignment of structures and union members Verifies that a function with a printf-style format string is called with the correct arguments Ensures that a symbol that is needed by another symbol is included in the linked output Adds a runtime model attribute to the module Verifies that a function with a scanf-style format string is called with the correct arguments Declares a section name to be used by intrinsic functions Sets the interrupt number of a software interrupt function Changes the declaration and definitions of a variable or function Makes a definition a weak definition, or creates a weak alias for a function or a variable
Note: For portability reasons, the pragma directives alignment, baseaddr, codeseg, constseg, dataseg, function, memory, and warnings are recognized but will give a diagnostic message. It is important to be aware of this if you need to port existing code that contains any of those pragma directives. See also Recognized pragma directives (6.8.6), page 355.
bitfields
Syntax
#pragma bitfields=disjoint_types|joined_types| reversed_disjoint_types|reversed|default}
Parameters
disjoint_types Bitfield members are placed from the least significant bit to the most significant bit in the container type. Storage containers of bitfields with different base types will not overlap.
246
Pragma directives
joined_types
Bitfield members are placed depending on the byte order. Storage containers of bitfields will overlap other structure members. For more details, see Bitfields, page 212.
reversed_disjoint_types Bitfield members are placed from the most significant bit to the least significant bit in the container type. Storage containers of bitfields with different base types will not overlap. reversed default This is an alias for reversed_disjoint_types. Restores to default layout of bitfield members. The default behavior for the compiler is joined_types.
Description Example
See also
data_alignment
Syntax Parameters
expression A constant which must be a power of two (1, 2, 4, etc.). #pragma data_alignment=expression
Description
Use this pragma directive to give a variable a higher (more strict) alignment of the start address than it would otherwise have. This directive can be used on variables with static and automatic storage duration. When you use this directive on variables with automatic storage duration, there is an upper limit on the allowed alignment for each function, determined by the calling convention used. Note: Normally, the size of a variable is a multiple of its alignment. The
data_alignment directive only affects the alignment of the variables start address,
247
and not its size, and can thus be used for creating situations where the size is not a multiple of the alignment.
diag_default
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117. #pragma diag_default=tag[,tag,...]
Description
Use this pragma directive to change the severity level back to the default, or to the severity level defined on the command line by any of the options --diag_error, --diag_remark, --diag_suppress, or --diag_warnings, for the diagnostic messages specified with the tags. Diagnostics, page 152.
See also
diag_error
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117. #pragma diag_error=tag[,tag,...]
Description
Use this pragma directive to change the severity level to error for the specified diagnostics. Diagnostics, page 152.
See also
diag_remark
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe177. #pragma diag_remark=tag[,tag,...]
248
Pragma directives
Description
Use this pragma directive to change the severity level to remark for the specified diagnostic messages. Diagnostics, page 152.
See also
diag_suppress
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe117. #pragma diag_suppress=tag[,tag,...]
Use this pragma directive to suppress the specified diagnostic messages. Diagnostics, page 152.
diag_warning
Syntax Parameters
tag The number of a diagnostic message, for example the message number Pe826. #pragma diag_warning=tag[,tag,...]
Description
Use this pragma directive to change the severity level to warning for the specified diagnostic messages. Diagnostics, page 152.
See also
include_alias
Syntax
#pragma include_alias ("orig_header" , "subst_header") #pragma include_alias (<orig_header> , <subst_header>)
Parameters
orig_header subst_header The name of a header file for which you want to create an alias. The alias for the original header file.
249
Description
Use this pragma directive to provide an alias for a header file. This is useful for substituting one header file with another, and for specifying an absolute path to a relative file. This pragma directive must appear before the corresponding #include directives and subst_header must match its corresponding #include directive exactly.
Example
This example will substitute the relative file stdio.h with a counterpart located according to the specified path. See also Include file search procedure, page 149.
inline
Syntax Parameters
forced Disables the compilers heuristics and forces inlining. #pragma inline[=forced]
Description
Use this pragma directive to advise the compiler that the function whose declaration follows immediately after the directive should be inlinedthat is, expanded into the body of the calling function. Whether the inlining actually occurs is subject to the compilers heuristics. This is similar to the C++ keyword inline, but has the advantage of being available in C code. Specifying #pragma inline=forced disables the compilers heuristics and forces inlining. If the inlining fails for some reason, for example if it cannot be used with the function type in question (like printf), an error message is emitted. Note: Because specifying #pragma inline=forced disables the compilers heuristics, including the inlining heuristics, the function declared immediately after the directive will not be inlined on optimization levels None or Low. No error or warning message will be emitted.
250
Pragma directives
language
Syntax Parameters
extended Turns on the IAR Systems language extensions and turns off the --strict_ansi command line option. Uses the language settings specified by compiler options. #pragma language={extended|default}
default
Description
Use this pragma directive to enable the compiler language extensions or for using the language settings specified on the command line.
location
Syntax Parameters
address The absolute address of the global or static variable for which you want an absolute location. A user-defined section name; cannot be a section name predefined for use by the compiler and linker. #pragma location={address|NAME}
NAME
Description
Use this pragma directive to specify the locationthe absolute addressof the global or static variable whose declaration follows the pragma directive. The variable must be declared either __no_init or const. Alternatively, the directive can take a string specifying a section for placing either a variable or a function whose declaration follows the pragma directive.
#pragma location=0xFFFF0400 __no_init volatile char PORT1; /* PORT1 is located at address 0xFFFF0400 */ #pragma location="foo" char PORT1; /* PORT1 is located in section foo */ /* A better way is to use a corresponding mechanism */ #define FLASH _Pragma("location=\"FLASH\"") ... FLASH int i; /* i is placed in the FLASH section */
Example
See also
251
message
Syntax Parameters
message The message that you want to direct to the standard output stream. #pragma message(message)
Description
Use this pragma directive to make the compiler print a message to the standard output stream when the file is compiled.
#ifdef TESTING #pragma message("Testing") #endif
Example:
object_attribute
Syntax Parameters
#pragma object_attribute=object_attribute[,object_attribute,...]
For a list of object attributes that can be used with this pragma directive, see Object attributes, page 235. Use this pragma directive to declare a variable or a function with an object attribute. This directive affects the definition of the identifier that follows immediately after the directive. The object is modified, not its type. Unlike the directive #pragma type_attribute that specifies the storing and accessing of a variable or function, it is not necessary to specify an object attribute in declarations.
#pragma object_attribute=__no_init char bar;
Description
Example
See also
optimize
Syntax Parameters
balanced|size|speed Optimizes balanced between speed and size, optimizes for size, or optimizes for speed Specifies the level of optimization Turns off code motion #pragma optimize=param[ param...]
none|low|medium|high no_code_motion
252
Pragma directives
Turns off common subexpression elimination Turns off function inlining Turns off type-based alias analysis Turns off loop unrolling Turns off instruction scheduling
Description
Use this pragma directive to decrease the optimization level, or to turn off some specific optimizations. This pragma directive only affects the function that follows immediately after the directive. The parameters speed, size, and balanced only have effect on the high optimization level and only one of them can be used as it is not possible to optimize for speed and size at the same time. It is also not possible to use preprocessor macros embedded in this pragma directive. Any such macro will not be expanded by the preprocessor. Note: If you use the #pragma optimize directive to specify an optimization level that is higher than the optimization level you specify using a compiler option, the pragma directive is ignored.
Example
#pragma optimize=speed int small_and_used_often() { ... } #pragma optimize=size no_inline int big_and_seldom_used() { ... }
pack
Syntax
#pragma pack(n) #pragma pack() #pragma pack({push|pop}[,name] [,n])
Parameters
n Empty list push Sets an optional structure alignment; one of: 1, 2, 4, 8, or 16 Restores the structure alignment to default Sets a temporary structure alignment
253
pop name
Restores the structure alignment from a temporarily pushed alignment An optional pushed or popped alignment label
Description
Use this pragma directive to specify the maximum alignment of struct and union members. The #pragma pack directive affects declarations of structures following the pragma directive to the next #pragma pack or end of file. Note: This can result in significantly larger and slower code when accessing members of the structure.
See also
__printf_args
Syntax Description
#pragma __printf_args
Use this pragma directive on a function with a printf-style format string. For any call to that function, the compiler verifies that the argument to each conversion specifier (for example %d) is syntactically correct.
#pragma __printf_args int printf(char const *,...);
Example
required
Syntax Parameters
symbol Any statically linked function or variable. #pragma required=symbol
Description
Use this pragma directive to ensure that a symbol which is needed by a second symbol is included in the linked output. The directive must be placed immediately before the second symbol.
254
Pragma directives
Use the directive if the requirement for a symbol is not otherwise visible in the application, for example if a variable is only referenced indirectly through the section it resides in. Example
const char copyright[] = "Copyright by me"; #pragma required=copyright int main() { /* Do something here. */ }
Even if the copyright string is not used by the application, it will still be included by the linker and available in the output.
rtmodel
Syntax Parameters
"key" "value" A text string that specifies the runtime model attribute. A text string that specifies the value of the runtime model attribute. Using the special value * is equivalent to not defining the attribute at all. #pragma rtmodel="key","value"
Description
Use this pragma directive to add a runtime model attribute to a module, which can be used by the linker to check consistency between modules. This pragma directive is useful for enforcing consistency between modules. All modules that are linked together and define the same runtime attribute key must have the same value for the corresponding key, or the special value *. It can, however, be useful to state explicitly that the module can handle any runtime model. A module can have several runtime model definitions. Note: The predefined compiler runtime model attributes start with a double underscore. To avoid confusion, this style must not be used in the user-defined attributes.
Example
#pragma rtmodel="I2C","ENABLED"
The linker will generate an error if a module that contains this definition is linked with a module that does not have the corresponding runtime model attributes defined. See also Checking module consistency, page 87.
255
__scanf_args
Syntax Description
#pragma __scanf_args
Use this pragma directive on a function with a scanf-style format string. For any call to that function, the compiler verifies that the argument to each conversion specifier (for example %d) is syntactically correct.
#pragma __scanf_args int printf(char const *,...);
Example
section
Syntax
#pragma section="NAME" [align]
alias
#pragma segment="NAME" [align]
Parameters
NAME align The name of the section or segment Specifies an alignment for the section. The value must be a constant integer expression to the power of two.
Description
Use this pragma directive to define a section name that can be used by the section operators __section_begin, __section_end, and __section_size. All section declarations for a specific section must have the same memory type attribute and alignment.
#pragma section="MYSECTION" 4
Dedicated section operators, page 223. For more information about sections, see the chapter Linking your application.
256
Pragma directives
swi_number
Syntax Parameters
number The software interrupt number #pragma swi_number=number
Description
Use this pragma directive together with the __swi extended keyword. It is used as an argument to the generated SWC assembler instruction, and is used for selecting one software interrupt function in a system containing several such functions.
#pragma swi_number=17
type_attribute
Syntax Parameters
#pragma type_attribute=type_attribute[,type_attribute,...]
For a list of type attributes that can be used with this pragma directive, see Type attributes, page 233. Use this pragma directive to specify IAR-specific type attributes, which are not part of the ISO/ANSI C language standard. Note however, that a given type attribute might not be applicable to all kind of objects. This directive affects the declaration of the identifier, the next variable, or the next function that follows immediately after the pragma directive.
Description
Example
See also
257
weak
Syntax Parameters
symbol1 symbol2 A function or variable with external linkage. A defined function or variable. #pragma weak symbol1={symbol2}
Description
To make the definition of a function or variable with external linkage a weak definition. The __weak attribute can also be used for this purpose. To create a weak alias for another function or variable. You can make more than one alias for the same function or variable.
Example
If NMI_Handler is not defined elsewhere in the program, all references to NMI_Handler will refer to Default_Handler. See also __weak, page 243.
258
Intrinsic functions
This chapter gives reference information about the intrinsic functions, a predefined set of functions available in the compiler. The intrinsic functions provide direct access to low-level processor operations and can be very useful in, for example, time-critical routines. The intrinsic functions compile into inline code, either as a single instruction or as a short sequence of instructions.
__CLZ __disable_fiq __disable_interrupt __disable_irq __DMB __DSB __enable_fiq __enable_interrupt __enable_irq __get_BASEPRI __get_CONTROL __get_CPSR __get_FAULTMASK __get_interrupt_state
Table 30: Intrinsic functions summary
Inserts a CLZ instruction Disables fast interrupt requests (fiq) Disables interrupts Disables interrupt requests (irq) Inserts a DMB instruction Inserts a DSB instruction Enables fast interrupt requests (fiq) Enables interrupts Enables interrupt requests (irq) Returns the value of the Cortex-M3 BASEPRI register Returns the value of the Cortex-M CONTROL register Returns the value of the ARM CPSR (Current Program Status Register) Returns the value of the Cortex-M3 FAULTMASK register Returns the interrupt state
259
Intrinsic function
Description
__get_PRIMASK __ISB __LDC __LDCL __LDC2 __LDC2L __LDC_noidx __LDCL_noidx __LDC2_noidx __LDC2L_noidx __LDREX __MCR __MRC __no_operation __QADD __QADD8 __QADD16 __QASX __QDADD __QDOUBLE __QDSUB __QFlag __QSUB __QSUB8 __QSUB16 __QSAX __REV __REVSH __SADD8 __SADD16 __SASX
Returns the value of the Cortex-M PRIMASK register Inserts a ISB instruction Inserts the coprocessor load instruction LDC Inserts the coprocessor load instruction LDCL Inserts the coprocessor load instruction LDC2 Inserts the coprocessor load instruction LDC2L Inserts the coprocessor load instruction LDC Inserts the coprocessor load instruction LDCL Inserts the coprocessor load instruction LDC2 Inserts the coprocessor load instruction LDC2L Inserts an LDREX instruction Inserts the coprocessor write instruction MCR Inserts the coprocessor read instruction MRC Inserts a NOP instruction Inserts a QADD instruction Inserts a QADD8 instruction Inserts a QADD16 instruction Inserts a QASX instruction Inserts a QDADD instruction Inserts a QADD instruction Inserts a QDSUB instruction Returns the Q flag that indicates if overflow/saturation has occurred Inserts a QSUB instruction Inserts a QSUB8 instruction Inserts a QSUB16 instruction Inserts a QSAX instruction Inserts a REV instruction Inserts a REVSH instruction Inserts a SADD8 instruction Inserts a SADD16 instruction Inserts a SASX instruction
260
Intrinsic functions
Intrinsic function
Description
__SEL __set_BASEPRI __set_CONTROL __set_CPSR __set_FAULTMASK __set_interrupt_state __set_PRIMASK __SHADD8 __SHADD16 __SHASX __SHSUB8 __SHSUB16 __SHSAX __SMUL __SSUB8 __SSUB16 __SSAX __STC __STCL __STC2 __STC2L __STC_noidx __STCL_noidx __STC2_noidx __STC2L_noidx __STREX __SWP __SWPB __UADD8 __UADD16 __UASX
Inserts a SEL instruction Sets the value of the Cortex-M3 BASEPRI register Sets the value of the Cortex-M CONTROL register Sets the value of the ARM CPSR (Current Program Status Register) Sets the value of the Cortex-M3 FAULTMASK register Restores the interrupt state Sets the value of the Cortex-M PRIMASK register Inserts a SHADD8 instruction Inserts a SHADD16 instruction Inserts a SHASX instruction Inserts a SHSUB8 instruction Inserts a SHSUB16 instruction Inserts a SHSAX instruction Inserts a signed 16-bit multiplication Inserts a SSUB8 instruction Inserts a SSUB16 instruction Inserts a SSAX instruction Inserts the coprocessor store instruction STC Inserts the coprocessor store instruction STCL Inserts the coprocessor store instruction STC2 Inserts the coprocessor store instruction STC2L Inserts the coprocessor store instruction STC Inserts the coprocessor store instruction STCL Inserts the coprocessor store instruction STC2 Inserts the coprocessor store instruction STC2L Inserts a STREX instruction Inserts an SWP instruction Inserts an SWPB instruction Inserts a UADD8 instruction Inserts a UADD16 instruction Inserts a UASX instruction
261
Intrinsic function
Description
__UHADD8 __UHADD16 __UHASX __UHSAX __UHSUB8 __UHSUB16 __UQADD8 __UQADD16 __UQASX __UQSUB8 __UQSUB16 __UQSAX __USAX __USUB8 __USUB16
Inserts a UHADD8 instruction Inserts a UHADD16 instruction Inserts a UHASX instruction Inserts a UHSAX instruction Inserts a UHSUB8 instruction Inserts a UHSUB16 instruction Inserts a UQADD8 instruction Inserts a UQADD16 instruction Inserts a UQASX instruction Inserts a UQSUB8 instruction Inserts a UQSUB16 instruction Inserts a UQSAX instruction Inserts a USAX instruction Inserts a USUB8 instruction Inserts a USUB16 instruction
__CLZ
Syntax Description
unsigned char __CLZ(unsigned long);
Inserts a CLZ instruction. This intrinsic function requires an ARM v5 architecture or higher for ARM mode, and ARM v6T2 or higher for Thumb mode.
__disable_fiq
Syntax Description
void __disable_fiq(void);
262
Intrinsic functions
This intrinsic function can only be used in privileged mode and is not available for Cortex-M devices.
__disable_interrupt
Syntax Description
void __disable_interrupt(void);
Disables interrupts. For Cortex-M devices, it raises the execution priority level to 0 by setting the priority mask bit, PRIMASK. For other devices, it disables interrupt requests (irq) and fast interrupt requests (fiq). This intrinsic function can only be used in privileged mode.
__disable_irq
Syntax Description
void __disable_irq(void);
Disables interrupt requests (irq). This intrinsic function can only be used in privileged mode and is not available for Cortex-M devices.
__DMB
Syntax Description
void __DMB(void);
Inserts a DMB instruction. This intrinsic function requires an ARM v7 architecture or higher.
__DSB
Syntax Description
void __DSB(void);
Inserts a DSB instruction. This intrinsic function requires an ARM v7 architecture or higher.
263
__enable_fiq
Syntax Description
void __enable_fiq(void);
Enables fast interrupt requests (fiq). This intrinsic function can only be used in privileged mode, and it is not available for Cortex-M devices.
__enable_interrupt
Syntax Description
void __enable_interrupt(void);
Enables interrupts. For Cortex-M devices, it resets the execution priority level to default by clearing the priority mask bit, PRIMASK. For other devices, it enables interrupt requests (irq) and fast interrupt requests (fiq). This intrinsic function can only be used in privileged mode.
__enable_irq
Syntax Description
void __enable_irq(void);
Enables interrupt requests (irq). This intrinsic function can only be used in privileged mode, and it is not available for Cortex-M devices.
__get_BASEPRI
Syntax Description
unsigned long __get_BASEPRI(void);
Returns the value of the BASEPRI register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M3 device.
__get_CONTROL
Syntax Description
unsigned long __get_CONTROL(void);
Returns the value of the CONTROL register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M device.
264
Intrinsic functions
__get_CPSR
Syntax Description
unsigned long __get_CPSR(void);
Returns the value of the ARM CPSR (Current Program Status Register). This intrinsic function can only be used in privileged mode, is not available for Cortex-M devices, and it requires ARM mode.
__get_FAULTMASK
Syntax Description
unsigned long __get_FAULTMASK(void);
Returns the value of the FAULTMASK register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M3 device.
__get_interrupt_state
Syntax Description
__istate_t __get_interrupt_state(void);
Returns the global interrupt state. The return value can be used as an argument to the __set_interrupt_state intrinsic function, which will restore the interrupt state. This intrinsic function can only be used in privileged mode, and cannot be used when using the --aeabi compiler option.
Example
The advantage of using this sequence of code compared to using __disable_interrupt and __enable_interrupt is that the code in this example will not enable any interrupts disabled before the call of __get_interrupt_state.
__get_PRIMASK
Syntax Description
unsigned long __get_PRIMASK(void);
Returns the value of the PRIMASK register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M device.
265
__ISB
Syntax Description
void __ISB(void);
Inserts a ISB instruction. This intrinsic function requires an ARM v7 architecture or higher.
Description
Inserts the coprocessor load instruction LDCor one of its variantswhich means that a value will be loaded into a coprocessor register. The parameters coproc and CRn will be encoded in the instruction and must therefore be constants.
266
Intrinsic functions
option
Description
Inserts the coprocessor load instruction LDC, or one of its variants. A value will be loaded into a coprocessor register. The parameters coproc, CRn, and option will be encoded in the instruction and must therefore be constants.
__LDREX
Syntax Description
unsigned long __LDREX(unsigned long *);
Inserts an LDREX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v6T2 or higher for Thumb mode.
__MCR
Syntax
void __MCR(__ul coproc, __ul opcode_1, __ul src, __ul CRn, __ul CRm, __ul opcode_2);
Parameters
coproc opcode_1 src CRn CRm opcode_2 The coprocessor number 0..15. Coprocessor-specific operation code. The value to be written to the coprocessor. The coprocessor register to write to. Additional coprocessor register; set to zero if not used. Additional coprocessor-specific operation code; set to zero if not used.
Description
Inserts a coprocessor write instruction (MCR). A value will be written to a coprocessor register. The parameters coproc, opcode_1, CRn, CRm, and opcode_2 will be encoded in the MCR instruction operation code and must therefore be constants. This intrinsic function requires either ARM mode, or an ARM v6T2 or higher for Thumb mode.
267
__MRC
Syntax
unsigned long __MRC(__ul coproc, __ul opcode_1, __ul CRn, __ul CRm, __ul opcode_2);
Parameters
coproc opcode_1 CRn CRm opcode_2 The coprocessor number 0..15. Coprocessor-specific operation code. The coprocessor register to write to. Additional coprocessor register; set to zero if not used. Additional coprocessor-specific operation code; set to zero if not used.
Description
Inserts a coprocessor read instruction (MRC). Returns the value of the specified coprocessor register. The parameters coproc, opcode_1, CRn, CRm, and opcode_2 will be encoded in the MRC instruction operation code and must therefore be constants. This intrinsic function requires either ARM mode, or an ARM v6T2 or higher for Thumb mode.
__no_operation
Syntax Description
void __no_operation(void);
__QADD
Syntax Description
signed long __QADD(signed long, signed long);
Inserts a QADD instruction. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QADD8
Syntax Description
unsigned long __QADD8(unsigned long, unsigned long);
268
Intrinsic functions
This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QADD16
Syntax Description
unsigned long __QADD16(unsigned long, unsigned long);
Inserts a QADD16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QASX
Syntax Description
unsigned long __QASX(unsigned long, unsigned long);
Inserts a QASX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QDADD
Syntax Description
signed long __QDADD(signed long, signed long);
Inserts a QDADD instruction. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QDOUBLE
Syntax Description
signed long __QDOUBLE(signed long);
Inserts an instruction QADD Rd,Rs,Rs for a source register Rs, and a destination register Rd. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
269
__QDSUB
Syntax Description
signed long __QDSUB(signed long, signed long);
Inserts a QDSUB instruction. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QFlag
Syntax Description
int __QFlag(void);
Returns the Q flag that indicates if overflow/saturation has occurred. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QSUB
Syntax Description
signed long __QSUB(signed long, signed long);
Inserts a QSUB instruction. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QSUB8
Syntax Description
unsigned long __QSUB8(unsigned long, unsigned long);
Inserts a QSUB8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QSUB16
Syntax Description
unsigned long __QSUB16(unsigned long, unsigned long);
270
Intrinsic functions
This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__QSAX
Syntax Description
unsigned long __QSAX(unsigned long, unsigned long);
Inserts a QSAX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__REV
Syntax Description
unsigned long __REV(unsigned long);
Inserts a REV instruction. This intrinsic function requires an ARM v6 architecture or higher.
__REVSH
Syntax Description
signed long __REVSH(short);
Inserts a REVSH instruction. This intrinsic function requires an ARM v6 architecture or higher.
__SADD8
Syntax Description
unsigned long __SADD8(unsigned long, unsigned long);
Inserts a SADD8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SADD16
Syntax Description
unsigned long __SADD16(unsigned long, unsigned long);
271
This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SASX
Syntax Description
unsigned long __SASX(unsigned long, unsigned long);
Inserts a SASX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SEL
Syntax Description
unsigned long __SEL(unsigned long, unsigned long);
Inserts a SEL instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__set_BASEPRI
Syntax Description
void __set_BASEPRI(unsigned long);
Sets the value of the BASEPRI register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M3 device.
__set_CONTROL
Syntax Description
void __set_CONTROL(unsigned long);
Sets the value of the CONTROL register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M device.
272
Intrinsic functions
__set_CPSR
Syntax Description
void __set_CPSR(unsigned long);
Sets the value of the ARM CPSR (Current Program Status Register). Only the control field is changed (bits 0-7). This intrinsic function can only be used in privileged mode, is not available for Cortex-M devices, and it requires ARM mode.
__set_FAULTMASK
Syntax Description
void __set_FAULTMASK(unsigned long);
Sets the value of the FAULTMASK register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M3 device.
__set_interrupt_state
Syntax Descriptions
void __set_interrupt_state(__istate_t);
Restores the interrupt state to a value previously returned by the __get_interrupt_state function. For information about the __istate_t type, see __get_interrupt_state, page 265.
__set_PRIMASK
Syntax Description
void __set_PRIMASK(unsigned long);
Sets the value of the PRIMASK register. This intrinsic function can only be used in privileged mode and it requires a Cortex-M device.
__SHADD8
Syntax Description
unsigned long __SHADD8(unsigned long, unsigned long);
Inserts a SHADD8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
273
__SHADD16
Syntax Description
unsigned long __SHADD16(unsigned long, unsigned long);
Inserts a SHADD16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SHASX
Syntax Description
unsigned long __SHASX(unsigned long, unsigned long);
Inserts a SHASX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SHSUB8
Syntax Description
unsigned long __SHSUB8(unsigned long, unsigned long);
Inserts a SHSUB8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SHSUB16
Syntax Description
unsigned long __SHSUB16(unsigned long, unsigned long);
Inserts a SHSUB16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SHSAX
Syntax Description
unsigned long __SHSAX(unsigned long, unsigned long);
274
Intrinsic functions
This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SMUL
Syntax Description
signed long __SMUL(signed short, signed short);
Inserts a signed 16-bit multiplication. This intrinsic function requires an ARM v5E architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SSUB8
Syntax Description
unsigned long __SSUB8(unsigned long, unsigned long);
Inserts a SSUB8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SSUB16
Syntax Description
unsigned long __SSUB16(unsigned long, unsigned long);
Inserts a SSUB16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__SSAX
Syntax Description
unsigned long __SSAX(unsigned long, unsigned long);
Inserts a SSAX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
275
Description
Inserts the coprocessor store instruction STCor one of its variantswhich means that the value of the specified coprocessor register will be written to a memory location. The parameters coproc and CRn will be encoded in the instruction and must therefore be constants.
Description
Inserts the coprocessor store instruction STCor one of its variantswhich means that the value of the specified coprocessor register will be written to a memory location. The parameters coproc, CRn, and option will be encoded in the instruction and must therefore be constants.
276
Intrinsic functions
__STREX
Syntax Description
unsigned long __STREX(unsigned long, unsigned long *);
Inserts a STREX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v6T2 or higher for Thumb mode.
__SWP
Syntax Description
unsigned long __SWP(unsigned long, unsigned long *);
__SWPB
Syntax Description
char __SWPB(unsigned char, unsigned char *);
__UADD8
Syntax Description
unsigned long __UADD8(unsigned long, unsigned long);
Inserts a UADD8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UADD16
Syntax Description
unsigned long __UADD16(unsigned long, unsigned long);
Inserts a UADD16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
277
__UASX
Syntax Description
unsigned long __UASX(unsigned long, unsigned long);
Inserts a UASX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UHADD8
Syntax Description
unsigned long __UHADD8(unsigned long, unsigned long);
Inserts a UHADD8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UHADD16
Syntax Description
unsigned long __UHADD16(unsigned long, unsigned long);
Inserts a UHADD16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UHASX
Syntax Description
unsigned long __UHASX(unsigned long, unsigned long);
Inserts a UHASX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UHSAX
Syntax Description
unsigned long __UHSAX(unsigned long, unsigned long);
278
Intrinsic functions
This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UHSUB8
Syntax Description
unsigned long __UHSUB8(unsigned long, unsigned long);
Inserts a UHSUB8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UHSUB16
Syntax Description
unsigned long __UHSUB16(unsigned long, unsigned long);
Inserts a UHSUB16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UQADD8
Syntax Description
unsigned long __UQADD8(unsigned long, unsigned long);
Inserts a UQADD8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UQADD16
Syntax Description
unsigned long __UQADD16(unsigned long, unsigned long);
Inserts a UQADD16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
279
__UQASX
Syntax Description
unsigned long __UQASX(unsigned long, unsigned long);
Inserts a UQASX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UQSUB8
Syntax Description
unsigned long __UQSUB8(unsigned long, unsigned long);
Inserts a UQSUB8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UQSUB16
Syntax Description
unsigned long __UQSUB16(unsigned long, unsigned long);
Inserts a UQSUB16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__UQSAX
Syntax Description
unsigned long __UQSAX(unsigned long, unsigned long);
Inserts a UQSAX instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__USAX
Syntax Description
unsigned long __USAX(unsigned long, unsigned long);
280
Intrinsic functions
This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__USUB8
Syntax Description
unsigned long __USUB8(unsigned long, unsigned long);
Inserts a USUB8 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
__USUB16
Syntax Description
unsigned long __USUB16(unsigned long, unsigned long);
Inserts a USUB16 instruction. This intrinsic function requires an ARM v6 architecture or higher for ARM mode, and ARM v7 with profile A or R for Thumb mode.
281
282
The preprocessor
This chapter gives a brief overview of the preprocessor, including reference information about the different preprocessor directives, symbols, and other related information.
Predefined preprocessor symbols These symbols allow you to inspect the compile-time environment, for example the time and date of compilation. For details, see Descriptions of predefined preprocessor symbols, page 284.
User-defined preprocessor symbols defined using a compiler option In addition to defining your own preprocessor symbols using the #define directive, you can also use the option -D, see -D, page 164.
Preprocessor extensions There are several preprocessor extensions, for example many pragma directives; for more information, see the chapter Pragma directives in this guide. Read also about the corresponding _Pragma operator and the other extensions related to the preprocessor, see Descriptions of miscellaneous preprocessor extensions, page 287.
Preprocessor output Use the option --preprocess to direct preprocessor output to a named file, see --preprocess, page 184.
Some parts listed by the ISO/ANSI standard are implementation-defined, for example the character set used in the preprocessor directives and inclusion of bracketed and quoted filenames. To read more about this, see Preprocessing directives, page 354.
283
__BASE_FILE__
A string that identifies the name of the base source file (that is, not the header file), being compiled. See also __FILE__, page 284, and --no_path_in_file_macros, page 178. A unique integer that identifies the build number of the compiler currently in use. An integer that identifies the processor architecture in use. The symbol reflects the --cpu option and is defined to __ARM4M__, __ARM4TM__, __ARM5__, __ARM5E__, __ARM6__, __ARM6M__, __ARM6SM__, __ARM7M__, or __ARM7R__. These symbolic names can be used when testing the __CORE__ symbol. An integer that reflects the --fpu option and is defined to 1 for VFPv1 and 2 for VFPv2. If VFP code generation is disabled (default), the symbol will be undefined. An integer which is defined when the compiler runs in any of the C++ modes, otherwise it is undefined. When defined, its value is 199711L. This symbol can be used with #ifdef to detect whether the compiler accepts C++ code. It is particularly useful when creating header files that are to be shared by C and C++ code.* An integer that reflects the selected CPU mode and is defined to 1 for Thumb and 2 for ARM. A string that identifies the date of compilation, which is returned in the form "Mmm dd yyyy", for example "Oct 30 2008". * An integer which is defined to 1 when the compiler runs in any of the C++ modes, otherwise the symbol is undefined. This symbol can be used with #ifdef to detect whether the compiler accepts C++ code. It is particularly useful when creating header files that are to be shared by C and C++ code.* A string that identifies the name of the file being compiled, which can be both the base source file and any included header file. See also __BASE_FILE__, page 284, and --no_path_in_file_macros, page 178.*
__BUILD_NUMBER__ __CORE__
__ARMVFP__
__cplusplus
__CPU_MODE__ __DATE__
__embedded_cplusplus
__FILE__
284
The preprocessor
Predefined symbol
Identifies
__func__
A string that identifies the name of the function in which the symbol is used. This is useful for assertions and other trace utilities. The symbol requires that language extensions are enabled, see -e, page 169. See also __PRETTY_FUNCTION__, page 285. A string that identifies the name of the function in which the symbol is used. This is useful for assertions and other trace utilities. The symbol requires that language extensions are enabled, see -e, page 169. See also __PRETTY_FUNCTION__, page 285. An integer that identifies the IAR compiler platform. The current value is 7. Note that the number could be higher in a future version of the product. This symbol can be tested with #ifdef to detect whether the code was compiled by a compiler from IAR Systems. An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for ARM, and otherwise to 0. An integer that identifies the current source line number of the file being compiled, which can be both the base source file and any included header file.* An integer that reflects the --endian option and is defined to 1 when the byte order is little-endian. The symbol is defined to 0 when the byte order is big-endian. A string that identifies the function name, including parameter types and return type, of the function in which the symbol is used, for example "void func(char)". This symbol is useful for assertions and other trace utilities. The symbol requires that language extensions are enabled, see -e, page 169. See also __func__, page 285. An integer that is set to 1, which means the compiler adheres to the ISO/ANSI C standard. This symbol can be tested with #ifdef to detect whether the compiler in use adheres to ISO/ANSI C.* An integer that identifies the version of ISO/ANSI C standard in use. The symbols expands to 199409L. This symbol does not apply in EC++ mode.* A string that identifies the time of compilation in the form "hh:mm:ss".*
__FUNCTION__
__IAR_SYSTEMS_ICC__
__ICCARM__ __LINE__
__LITTLE_ENDIAN__
__PRETTY_FUNCTION__
__STDC__
__STDC_VERSION__
__TIME__
285
Predefined symbol
Identifies
__VER__
An integer that identifies the version number of the IAR compiler in use. For example, version 5.11.3 is returned as 5011003.
__TID__
Description Target identifier for the IAR C/C++ Compiler for ARM. Expands to the target identifier which contains the following parts:
A one-bit intrinsic flag (i) which is reserved for use by IAR A target identifier (t) unique for each IAR compiler. For the ARM compiler, the target identifier is 79 A value (c) reserved for specifying different CPU core families. The value is derived from the setting of the --cpu option:
CPU core family
Value
0 1 2 3 4 5 6 7 8
Unspecified ARM7TDMI ARM9TDMI ARM9E ARM10E ARM11 CortexM3 CortexM0 or CortexM1 CortexR4
Table 32: Values for specifying different CPU core families in __TID__
286
The preprocessor
To find the value of the target identifier for the current compiler, execute:
printf("%ld",(__TID__ >> 8) & 0x7F)
Note: Because coding may change or functionality may be entirely removed in future versions, the use of __TID__ is not recommended. We recommend that you use the symbols __ICCARM__ and __CORE__ instead.
NDEBUG
Description This preprocessor symbol determines whether any assert macros you have written in your application shall be included or not in the built application. If this symbol is not defined, all assert macros are evaluated. If the symbol is defined, all assert macros are excluded from the compilation. In other words, if the symbol is:
defined, the assert code will not be included not defined, the assert code will be included
This means that if you write any assert code and build your application, you should define this symbol to exclude the assert code from the final application. Note that the assert macro is defined in the assert.h standard include file. See also Assert, page 85. In the IDE, the NDEBUG symbol is automatically defined if you build your application in the Release build configuration.
_Pragma()
Syntax
_Pragma("string")
where string follows the syntax of the corresponding pragma directive. Description This preprocessor operator is part of the C99 standard and can be used, for example, in defines and is equivalent to the #pragma directive. Note: The -e optionenable language extensionsdoes not have to be specified.
287
Example
See also
#warning message
Syntax
#warning message
where message can be any string. Description Use this preprocessor directive to produce messages. Typically, this is useful for assertions and other trace utilities, similar to the way the ISO/ANSI standard #error directive is used.
__VA_ARGS__
Syntax
#define P(...) __VA_ARGS__ #define P(x, y, ...) x + y + __VA_ARGS__ __VA_ARGS__ will contain all variadic arguments concatenated, including the
separating commas. Description Variadic macros are the preprocessor macro equivalents of printf style functions.
__VA_ARGS__ is part of the C99 standard.
Example
#if DEBUG #define DEBUG_TRACE(S, ...) printf(S, __VA_ARGS__) #else #define DEBUG_TRACE(S, ...) #endif /* Place your own code here */ DEBUG_TRACE("The value is:%d\n",value);
288
Library functions
This chapter gives an introduction to the C and C++ library functions. It also lists the header files used for accessing library definitions. For detailed reference information about the library functions, see the online help system.
Introduction
The compiler comes with the IAR DLIB Library, a complete ISO/ANSI C and C++ library. This library also supports floating-point numbers in IEEE 754 format and it can be configured to include different levels of support for locale, file descriptors, multibyte characters, et cetera. For additional information, see the chapter The DLIB runtime environment. For detailed information about the library functions, see the online documentation supplied with the product. There is also keyword reference information for the DLIB library functions. To obtain reference information for a function, select the function name in the editor window and press F1. For additional information about library functions, see the chapter Implementation-defined behavior in this guide.
HEADER FILES
Your application program gains access to library definitions through header files, which it incorporates using the #include directive. The definitions are divided into several different header files, each covering a particular functional area, letting you include just those that are required. It is essential to include the appropriate header file before making any reference to its definitions. Failure to do so can cause the call to fail during execution, or generate error or warning messages at compile time or link time.
289
REENTRANCY
A function that can be simultaneously invoked in the main application and in any number of interrupts is reentrant. A library function that uses statically allocated data is therefore not reentrant. Most parts of the DLIB library are reentrant, but these functions and parts are not reentrant because they need static data:
Heap functionsmalloc, free, realloc, calloc, and the C++ operators new and delete Time functionsasctime, localtime, gmtime, mktime Multibyte functionsmbrlen, mbrtowc, mbsrtowc, wcrtomb, wcsrtomb,
wctomb
The miscellaneous functions setlocale, rand, atexit, strerror, strtok Functions that use files in some way. This includes printf, scanf, getchar, and putchar. The functions sprintf and sscanf are not included.
Some functions also share the same storage for errno. These functions are not reentrant, since an errno value resulting from one of these functions can be destroyed by a subsequent use of the function before it is read. Among these functions are:
exp, exp10, ldexp, log, log10, pow, sqrt, acos, asin, atan2, cosh, sinh, strtod, strtol, strtoul
Do not use non-reentrant functions in interrupt service routines Guard calls to a non-reentrant function by a mutex, or a secure region, etc.
Adherence to a free-standing implementation of the ISO/ANSI standard for the programming language C. For additional information, see the chapter Implementation-defined behaviour in this guide. Standard C library definitions, for user programs. Embedded C++ library definitions, for user programs.
CSTARTUP, the module containing the start-up code. It is described in the chapter
290
Library functions
Intrinsic functions, allowing low-level use of ARM features. See the chapter Intrinsic functions for more information.
In addition, the IAR DLIB Library includes some added C functionality, partly taken from the C99 standard, see Added C functionality, page 294.
C HEADER FILES
This section lists the header files specific to the DLIB library C definitions. Header files may additionally contain target-specific definitions; these are documented in the chapter Compiler extensions. The following table lists the C header files:
Header file Usage
assert.h ctype.h errno.h float.h inttypes.h iso646.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stdbool.h stddef.h stdint.h stdio.h stdlib.h string.h time.h wchar.h wctype.h
Enforcing assertions when functions execute Classifying characters Testing error codes reported by library functions Testing floating-point type properties Defining formatters for all types defined in stdint.h Using Amendment 1iso646.h standard header Testing integer type properties Adapting to different cultural conventions Computing common mathematical functions Executing non-local goto statements Controlling various exceptional conditions Accessing a varying number of arguments Adds support for the bool data type in C. Defining several useful types and macros Providing integer characteristics Performing input and output Performing a variety of operations Manipulating several kinds of strings Converting between various time and date formats Support for wide characters Classifying wide characters
291
Embedded C++
The following table lists the Embedded C++ header files:
Header file Usage
complex exception fstream iomanip ios iosfwd iostream istream new ostream sstream stdexcept streambuf string strstream
Defining a class that supports complex arithmetic Defining several functions that control exception handling Defining several I/O stream classes that manipulate external files Declaring several I/O stream manipulators that take an argument Defining the class that serves as the base for many I/O streams classes Declaring several I/O stream classes before they are necessarily defined Declaring the I/O stream objects that manipulate the standard streams Defining the class that performs extractions Declaring several functions that allocate and free storage Defining the class that performs insertions Defining several I/O stream classes that manipulate string containers Defining several classes useful for reporting exceptions Defining classes that buffer I/O stream operations Defining a class that implements a string container Defining several I/O stream classes that manipulate in-memory character sequences
Defining several I/O stream classes that manipulate external files Declaring several I/O stream manipulators that take an argument Declaring the I/O stream objects that manipulate the standard streams Declaring several functions that allocate and free storage
292
Library functions
algorithm deque functional hash_map hash_set iterator list map memory numeric queue set slist stack utility vector
Defines several common operations on sequences A deque sequence container Defines several function objects A map associative container, based on a hash algorithm A set associative container, based on a hash algorithm Defines common iterators, and operations on iterators A doubly-linked list sequence container A map associative container Defines facilities for managing memory Performs generalized numeric operations on sequences A queue sequence container A set associative container A singly-linked list sequence container A stack sequence container Defines several utility components A vector sequence container
Enforcing assertions when functions execute Classifying characters Testing error codes reported by library functions Testing floating-point type properties Defining formatters for all types defined in stdint.h
293
Header file
Usage
climits clocale cmath csetjmp csignal cstdarg cstdbool cstddef cstdint cstdio cstdlib cstring ctime cwchar cwctype
Testing integer type properties Adapting to different cultural conventions Computing common mathematical functions Executing non-local goto statements Controlling various exceptional conditions Accessing a varying number of arguments Adds support for the bool data type in C. Defining several useful types and macros Providing integer characteristics Performing input and output Performing a variety of operations Manipulating several kinds of strings Converting between various time and date formats Support for wide characters Classifying wide characters
ADDED C FUNCTIONALITY
The IAR DLIB Library includes some added C functionality, partly taken from the C99 standard. The following include files provide these features:
294
Library functions
wctype.h
ctype.h
In ctype.h, the C99 function isblank is defined.
inttypes.h
This include file defines the formatters for all types defined in stdint.h to be used by the functions printf, scanf, and all their variants.
math.h
In math.h all functions exist in a float variant and a long double variant, suffixed by f and l respectively. For example, sinf and sinl. The following C99 macro symbols are defined:
HUGE_VALF, HUGE_VALL, INFINITY, NAN, FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, MATH_ERRNO, MATH_ERREXCEPT, math_errhandling.
stdbool.h
This include file makes the bool type available if the Allow IAR extensions (-e) option is used.
stdint.h
This include file provides integer characteristics.
stdio.h
In stdio.h, the following C99 functions are defined:
vscanf, vfscanf, vsscanf, vsnprintf, snprintf
The functions printf, scanf, and all their variants have added functionality from the C99 standard. For reference information about these functions, see the library reference available from the Help menu.
295
The following functions providing I/O functionality for libraries built without FILE support are defined:
__write_array Corresponds to fwrite on stdout. __ungetchar __gets
stdlib.h
In stdlib.h, the following C99 functions are defined:
_Exit, llabs, lldiv, strtoll, strtoull, atoll, strtof, strtold.
The function strtod has added functionality from the C99 standard. For reference information about this functions, see the library reference available from the Help menu. The __qsortbbl function is defined; it provides sorting using a bubble sort algorithm. This is useful for applications that have a limited stack.
wchar.h
In wchar.h, the following C99 functions are defined:
vfwscanf, vswscanf, vwscanf, wcstof, wcstolb.
wctype.h
In wctype.h, the C99 function iswblank is defined.
296
Overview
To link and locate an application in memory according to your requirements, ILINK needs information about how to handle sections and how to place them into the available memory regions. In other words, ILINK needs a configuration, passed to it by means of the linker configuration file. This file consists of a sequence of directives and typically, provides facilities for:
Defining available addressable memories giving the linker information about the maximum size of possible addresses and defining the available physical memory, as well as dealing with memories that can be addressed in different ways.
Defining the regions of the available memories that are populated with ROM or RAM giving the start and end address for each region. Section groups dealing with how to group sections into blocks and overlays depending on the section requirements.
Defining how to handle initialization of the application giving information about which sections that are to be initialized, and how that initialization should be made.
Memory allocation defining wherein what memory regioneach set of sections should be placed. Using symbols, expressions, and numbers expressing addresses and sizes, etc, in the other configuration directives. The symbols can also be used in the application itself.
297
Structural configuration meaning that you can include or exclude directives depending on a condition, and to split the configuration file into several different files.
The maximum size of possible addressable memories The define memory directive defines a memory space with a given size, which is the maximum possible amount of addressable memory, not necessarily physically available. See Define memory directive, page 298.
Available physical memory The define region directive defines a region in the available memories in which specific sections of application code and sections of application data can be placed. See Define region directive, page 299. A region consists of one or several memory ranges. A range is a continuous sequence of bytes in a memory and several ranges can be expressed by using region expressions. See Region expression, page 301.
bitsize_expr bytesize_expr
298
Description
The define memory directive defines a memory space with a given size, which is the maximum possible amount of addressable memory, not necessarily physically available. This sets the limits for the possible addresses to be used in the linker configuration file. For many microcontrollers, one memory space is sufficient. However, some microcontrollers require two or more. For example, a Harvard architecture usually requires two different memory spaces, one for code and one for data. If only one memory is defined, the memory name is optional. If no unit-size is given, the unit contains 8 bits.
/* Declare the memory space Mem of four Gigabytes */ define memory Mem with size = 4G;
Example
where region-expr is a region expression, see also Regions, page 299. Parameters
name The name of the region.
Description
The define region directive defines a region in which specific sections of code and sections of data can be placed. A region consists of one or several memory ranges, where each memory range consists of a continuous sequence of bytes in a specific memory. Several ranges can be combined by using region expressions. Note that those ranges do not need to be consecutive or even in the same memory.
/* Define the 0x10000-byte code region ROM located at address 0x10000 in memory Mem */ define region ROM = Mem:[from 0x10000 size 0x10000];
Example
Regions
A region is s a set of non-overlapping memory ranges. A region expression is built up out of region literals and set operations (union, intersection, and difference) on regions.
Region literal
Syntax
[ memory-name: ][from expr { to expr | size expr } [ repeat expr [ displacement expr ]]]
299
Regions
Description
A region literal consists of one memory range. When you define a range, the memory it resides in, a start address, and a size must be specified. The range size can be stated explicitly by specifying a size, or implicitly by specifying the final address of the range. The final address is included in the range and a zero-sized range will only contain an address. A range can span over the address zero and the range can even be expressed by unsigned values, because it is known where the memory wraps. The repeat parameter will create a region literal that contains several ranges, one for each repeat. This is useful for banked or far regions.
Example
/* The 5-byte size range spans over the address zero */ Mem:[from -2 to 2] /* The 512-byte size range spans over zero, in a 64-Kbyte memory */ Mem:[from 0xFF00 to 0xFF] /* Defining several ranges in the same memory, a repeating literal */ Mem:[from 0 size 0x100 repeat 3 displacement 0x1000] /* Resulting Mem:[from Mem:[from Mem:[from */ in a region containing: 0 size 0x100] 0x1000 size 0x100] 0x2000 size 0x100]
See also
Define region directive, page 299, and Region expression, page 301.
300
Region expression
Syntax
region-operand | region-expr | region-operand | region-expr - region-operand | region-expr & region-operand
where region-name is a region, see Define region directive, page 299 where region-literal is a region literal, see Region literal, page 299 and where empty-region is an empty region, see Empty region, page 302. Description Normally, a region consists of one memory range, which means a region literal is sufficient to express it. When a region contains several ranges, possibly in different memories, it is instead necessary to use a region expression to express it. Region expressions are actually set expressions on sets of memory ranges. To create region expressions, three operators are available: union (|), intersection (&), and difference (-). These operators work as in set theory. For example, if you have the sets A and B, then the result of the operators would be:
A | B: all elements in either set A or set B A & B: all elements in both set A and B A - B: all elements in set A but not in B.
Example
/* Resulting in a range starting at 1000 and ending at 2FFF, in memory Mem */ Mem:[from 0x1000 to 0x1FFF] | Mem:[from 0x1500 to 0x2FFF] /* Resulting in a range starting at 1500 and ending at 1FFF, in memory Mem */ Mem:[from 0x1000 to 0x1FFF] & Mem:[from 0x1500 to 0x2FFF] /* Resulting in a range starting at 1000 and ending at 14FF, in memory Mem */ Mem:[from 0x1000 to 0x1FFF] - Mem:[from 0x1500 to 0x2FFF]
301
Section handling
/* Resulting in two ranges. The first starting at 1000 and ending at 1FFF, the second starting at 2501 and ending at 2FFF. Both located in memory Mem */ Mem:[from 0x1000 to 0x2FFF] - Mem:[from 0x2000 to 0x24FF]
Empty region
Syntax Description
[ ]
The empty region does not contain any memory ranges. If the empty region is used in a placement directive that actually is used for placing one or more sections, ILINK will issue an error.
define region Code = Mem:[from 0 size 0x10000]; if (Banked) { define region Bank = Mem:[from 0x8000 size 0x1000]; } else { define region Bank = []; } define region NonBanked = Code - Bank; /* Depending on the Banked symbol, the NonBanked region is either one range with 0x10000 bytes, or two ranges with 0x8000 and 0x7000 bytes, respectively. */
Example
See also
Section handling
Section handling describes how ILINK should handle the sections of the execution image, which means:
Placing sections in regions The place at and place into directives place sets of sections with similar attributes into previously defined regions. See Place at directive, page 309 and Place in directive, page 310.
Making sets of sections with special requirements The block directive makes it possible to create empty sections with specific sizes and alignments, sequentially sorted sections of different types, etc. The overlay directive makes it possible to create an area of memory that can contain several overlay images. See Define block directive, page 303, and Define overlay directive, page 304.
302
Initializing the application The directives initialize and do not initialize control how the application should be started. With these directives, the application can initialize global symbols at startup, and copy pieces of code. The initializers can be stored in several ways, for example they can be compressed. See Initialize directive, page 305 and Do not initialize directive, page 308.
Keeping removed sections The keep directive retains sections even though they are not referred to by the rest of the application, which means it is equivalent to the root concept in the assembler and compiler. See Keep directive, page 309.
and where the rest of the directive selects sections to include in the block, see Section selection, page 311. Parameters
name size The name of the defined block. Customizes the size of the block. By default, the size of a block is the sum of its parts dependent of its contents. Specifies an upper limit for the size of the block. An error is generated if the sections in the block do not fit. Specifies a minimum alignment for the block. If any section in the block has a higher alignment than the minimum alignment, the block will have that alignment.
maximum size
alignment
303
Section handling
fixed order
Places sections in fixed order; if not specified, the order of the sections will be arbitrary.
Description
The block directive defines a named set of sections. By defining a block you can create empty blocks of bytes that can be used, for example as stacks or heaps. Another use for the directive is to group certain types of sections, consecutive or non-consecutive. A third example of use for the directive is to group sections into one memory area to access the start and end of that area from the application.
/* Create a 0x1000-byte block for the heap */ define block HEAP with size = 0x1000, alignment = 8 { };
Example
See also
Interaction between the tools and your application, page 117. See Define overlay directive, page 304 for an accessing example.
For information about extended selectors and except clauses, see Section selection, page 311. Parameters
name size The name of the overlay. Customizes the size of the overlay. By default, the size of a overlay is the sum of its parts dependent of its contents. Specifies an upper limit for the size of the overlay. An error is generated if the sections in the overlay do not fit. Specifies a minimum alignment for the overlay. If any section in the overlay has a higher alignment than the minimum alignment, the overlay will have that alignment. Places sections in fixed order; if not specified, the order of the sections will be arbitrary.
maximum size
alignment
fixed order
304
Description
The overlay directive defines a named set of sections. In contrast to the block directive, the overlay directive can define the same name several times. Each definition will then be grouped in memory at the same place as all other definitions of the same name. This creates an overlaid memory area, which can be useful for an application that has several independent sub-applications. Place each sub-application image in ROM and reserve a RAM overlay area that can hold all sub-applications. To execute a sub-application, first copy it from ROM to the RAM overlay. Note that ILINK does not help you with managing interdependent overlay definitions, apart from generating a diagnostic message for any reference from one overlay to another overlay. The size of an overlay will be the same size as the largest definition of that overlay name and the alignment requirements will be the same as for the definition with the highest alignment requirements. Note: Sections that were overlaid must be split into a RAM and a ROM part and you must take care of all the copying needed.
See also
Initialize directive
Syntax
initialize { by copy | manually [ with param, param... ] { section-selectors } [except { section_selectors }];
and where the rest of the directive selects sections to include in the block. See Section selection, page 311. Parameters
by copy Splits the section into sections for initializers and initialized data, and handles the initialization at application startup automatically.
305
Section handling
manually
Splits the section into sections for initializers and initialized data. The initialization at application startup is not handled automatically. Specifies how to handle the initializers. Choose between: none Disables compression of the selected section contents. This is the default method for initialize manually. Compresses sequential bytes with the value zero. Compresses with the PackBits algorithm. This method generates good results for data with many consecutive bytes of the same value. Compresses with the Burrows-Wheeler algorithm. This method improves the packbits method by transforming blocks of data before they are compressed. Compresses with the Lempel-Ziv-Welch algorithm. This method uses a dictionary to store byte patterns in the data. Similar to smallest, but ILINK chooses between none and packbits. This is the default method for initialize by copy. ILINK estimates the resulting size using each packing method (except for auto), and then chooses the packing method that produces the smallest estimated size. Note that the size of the decompressor is also included.
packing
zeros
packbits
bwt
lzw
auto
smallest
copy routine
Uses your own initialization routine instead of the default routine. It will be automatically called at the application startup.
Description
The initialize directive splits the initialization section into one section holding the initializers and another section holding the initialized data. You can choose whether the initialization at startup should be handled automatically (initialize by copy) or whether you should handle it yourself (initialize manually).
306
When you use the packing method auto (default for initialize by copy) or smallest, ILINK will automatically choose an appropriate packing algorithm for the initializers and automatically revert it at the initialization process when the application starts. To override this, specify a different packing method. Use the copy routine parameter to override the method for copying the initializers. The --log initialization option shows how ILINK decided which packing algorithm to use. When initializers are compressed, a decompressor is automatically added to the image. The decompressors for bwt and lzw use significantly more execution time and RAM than zeros and packbits. Approximately 9 Kbytes of stack space is needed for bwt and 3.5 Kbytes for lzw. When initializers are compressed, the exact size of the compressed initializers is unknown until the exact content of the uncompressed data is known. If this data contains other addresses, and some of these addresses are dependent on the size of the compressed initializers, the linker fails with error Lp017. To avoid this, place compressed initializers last, or in a memory region together with sections whose addresses do not need to be known. Optionally, ILINK will also produce a table that an initialization function in the system startup code uses for copying the section contents from the initializer sections to the corresponding original sections. Normally, the section content is initialized variables. Zero-initialized sections are not affected by the initialize directive. Sections that must execute before the initialization finishes are not affected by the
initialize by copy directive. This includes the __low_level_init function and
anything it references. Anything reachable from the program entry label is considered needed for initialization unless reached via a section fragment with a label starting with __iar_init$$done. The --log sections option can be used for creating a log of this process (in addition to the more general process of marking section fragments to be included in the application). The initialize directive can be used for copying other things as well, for example copying executable code from slow ROM to fast RAM. For another example, see Define overlay directive, page 304. Example
/* Copy all read-write sections automatically from ROM to RAM at program start */ initialize by copy { rw }; place in RAM { rw }; place in ROM { ro };
307
Section handling
/* Initialize special sections (initializers placed in flash) */ initialize by copy with packing = none, copy routine = my_initializers { section .special }; place in RAM { section .special }; place in ROM { section .special_init };
See also
Initialization at system startup, page 45, and Do not initialize directive, page 308.
For information about extended selectors and except clauses, see Section selection, page 311. Description The do not initialize directive specifies the sections that should not be initialized by the system startup code. The directive can only be used on zeroinit sections. The compiler keyword __no_init places variables into sections that must be handled by a do not initialize directive. Example
/* Do not initialize read-write sections whose name ends with _noinit at program start */ do not initialize { rw section .*_noinit }; place in RAM { rw section .*_noinit };
See also
Initialization at system startup, page 45, and Initialize directive, page 305.
308
Keep directive
Syntax
keep { section-selectors } [except { section-selectors }];
For information about extended selectors and except clauses, see Section selection, page 311. Description The keep directive specifies that all selected sections should be kept in the executable image, even if there are no references to the sections.
keep { section .keep* } except {section .keep};
Example
Place at directive
Syntax
[ "name": ] place at { address [ memory: ] expr | start of region_expr | end of region_expr } { extended-selectors } [except { section-selectors }];
For information about extended selectors and except clauses, see Section selection, page 311. Parameters
memory: expr A specific address in a specific memory. The address must be available in the supplied memory defined by the define memory directive. The memory specifier is optional if there is only one memory.
start of region_expr A region expression. The start of the region is used. end of region_expr A region expression. The end of the region is used.
309
Section handling
Description
The place at directive places sections and blocks either at a specific address or, at the beginning or the end of a region. The same address cannot be used for two different place at directives. It is also not possible to use an empty region in a place at directive. If placed in a region, the sections and blocks will be placed before any other sections or blocks placed in the same region with a place in directive. The sections and blocks will be placed in the region in an arbitrary order. To specify a specific order, use the block directive. The name, if specified, is used in the map file and in some log messages.
Example
/* Place the read-only section .startup at the beginning of the code_region */ "START": place at start of ROM { readonly section .startup };
See also
Place in directive
Syntax
[ "name": ] place in region-expr { extended-selectors } [{ section-selectors }];
where region-expr is a region expression, see also Regions, page 299. and where the rest of the directive selects sections to include in the block. See Section selection, page 311. Description The place in directive places sections and blocks in a specific region. The sections and blocks will be placed in the region in an arbitrary order. To specify a specific order, use the block directive. The region can have several ranges. The name, if specified, is used in the map file and in some log messages. Example
/* Place the read-only sections in the code_region */ "ROM": place in ROM { readonly };
See also
310
Section selection
The purpose of section selection is to specifyby means of section selectors and except clausesthe sections that an ILINK directive should be applied to. All sections that match one or more of the section selectors will be selected, and none of the sections selectors in the except clause, if any. Each section selector can match sections on section attributes, section name, and object or library name. Some directives provide functionality that requires more detailed selection capabilities, for example directives that can be applied on both sections and blocks. In this case, the extended-selectors are used.
Section-selectors
Syntax
{
module
311
Section selection
filename
The name of an object file, a library, or an object in a library. Two wildcards are allowed: ? matches any single character * matches zero or more characters.
Description
A section selector selects all sections that match the section attribute, section name, and the name of the object, where object is an object file, a library, or an object in a library. It is only possible to omit one or two of the three conditions. If the section attribute is omitted, any section will be selected, without restrictions on the section attribute. If the section name part or the object name part is omitted, sections will be selected without restrictions on the section name or object name, respectively. It is also possible to use only { } without any section selectors, which can be useful when defining blocks. Note that a section selector with narrower scope has higher priority than a more generic section selector.
Example
{ rw }
{ section .mydata* } /* Selects only .mydata* sections */ /* Selects .mydata* sections available in the object special.o */ { section .mydata* object special.o }
Assuming a section in an object named foo.o in a library named lib.a, any of these selectors will select that section:
object object object object foo.o(lib.a) f*(lib*) foo.o lib.a
See also
Initialize directive, page 305, Do not initialize directive, page 308, and Keep directive, page 309.
312
Extended-selectors
Syntax
{
[ extended-selector ][, extended-selector...] } [ first | last ]{ section-selector | block name [ inline-block-def ]| overlay name }
[ block-params ] extended-selectors
Parameters
first last block overlay Places the selected name first in the region, block, or overlay. Places the selected name last in the region, block, or overlay. The name of the block. The name of the overlay.
Description
In addition to what the section-selector does, extended-selector provides functionality for placing blocks or overlays first or last in a set of sections, a block, or an overlay. It is also possible to create an inline definition of a block. This means that you can get more precise control over section placement.
define block First { section .first }; /* Define a block holding the section .first */ define block Table { first block First }; /* Define a block where the first is placed first */
Example
See also
Define block directive, page 303, Define overlay directive, page 304, and Place at directive, page 309.
Define and export symbols The define symbol directive defines a symbol with a specified value that can be used in expressions in the configuration file. The symbol can also be exported to be
313
used by the application or the debugger. See Define symbol directive, page 314, and Export directive, page 315.
Use expressions and numbers In the linker configuration file, expressions and numbers are used for specifying addresses, sizes, et cetera. See Expressions, page 315.
Description
The define symbol directive defines a symbol with a specified value. The symbol can then be used in expressions in the configuration file. The symbols defined in this way work exactly like the symbols defined with the option --config_def outside of the configuration file. The define exported symbol variant of this directive is a shortcut for using the directive define symbol in combination with the export symbol directive. On the command line this would require both a --config_def option and a --define_symbol option to achieve the same effect. Note:
A symbol cannot be redefined Symbols that are either prefixed by _X, where X is a capital letter, or that contain __ (double underscore) are reserved for toolset vendors.
Example
/* Define the symbol my_symbol with the value 4 */ define symbol my_symbol = 4;
See also
Export directive, page 315 and Interaction between ILINK and the application, page 56.
314
Export directive
Syntax Parameters
name The name of the symbol. export symbol name;
Description
The export directive defines a symbol to be exported, so that it can be used both from the executable image and from a global label. The application, or the debugger, can then refer to it for setup purposes etc.
/* Define the symbol my_symbol to be exported */ export symbol my_symbol;
Example
Expressions
Syntax An expression is built up of the following constituents:
expression binop expression unop expression expression ? expression : expression (expression) number symbol func-operator
where number is a number, see Numbers, page 316 where symbol is a defined symbol, see Define symbol directive, page 314 and --config_def, page 192 and where func-operator is one of these function-like operators:
minimum(expr,expr) maximum(expr,expr) isempty(r) Returns the smallest of the two parameters. Returns the largest of the two parameters. Returns True if the region is empty, otherwise False.
315
isdefinedsymbol(expr-symbol) Returns True if the expression symbol is defined, otherwise False. start(r) end(r) size(r) Returns the lowest address in the region. Returns the highest address in the region. Returns the size of the complete region.
where expr is an expression, and r is a region expression, see Region expression, page 301. Description In the linker configuration file, an expression is a 65-bit value with the range -2^64 to 2^64. The expression syntax closely follows C syntax with some minor exceptions. There are no assignments, casts, pre- or post-operations, and no address operations (*, &, [], ->, and .). Some operations that extract a value from a region expression, etc, use a syntax resembling that of a function call. A boolean expression returns 0 (false) or 1 (true).
Numbers
Syntax
nr [nr-suffix]
where nr is either a decimal number or a hexadecimal number (0x... or 0X...). and where nr-suffix is one of:
K M G T P /* /* /* /* /* Kilo Mega Giga Tera Peta = = = = = (1 (1 (1 (1 (1 << << << << << 10) 20) 30) 40) 50) 1024 */ 1048576 */ 1073741824 */ 1099511627776 */ 1125899906842624 */
Description
A number can be expressed either by normal C means or by suffixing it with a set of useful suffixes, which provides a compact way of specifying numbers.
1024 is the same as 0x400, which is the same as 1K.
Example
316
Structural configuration
The structural directives provide means for creating structure within the configuration, such as:
Conditional inclusion An if directive includes or excludes other directives depending on a condition, which makes it possible to have directives for several different memory configurations in the same file. See If directive, page 317.
Dividing the linker configuration file into several different files The include directive makes it possible to divide the configuration file into several logically distinct files. See Include directive, page 318.
If directive
Syntax
if (expr) { directives [ } else if (expr) { directives ] [ } else { directives ] }
Description
An if directive includes or excludes other directives depending on a condition, which makes it possible to have directives for several different memory configurations, for example both a banked and non-banked memory configuration, in the same file. The directives inside an if part, else if part, or an else part are syntax checked and processed regardless of whether the conditional expression was true or false, but only the directives in the part where the conditional expression was true, or the else part if none of the conditions were true, will have any effect outside the if directive. The if directives can be nested.
Example
317
Structural configuration
Include directive
Syntax Parameters
filename A string literal where both / and \ can be used as the directory delimiter. include filename;
Description
The include directive makes it possible to divide the configuration file into several logically distinct files. For instance, files that you need to change often and files that you seldom edit.
318
Section reference
The compiler places code and data into sections. Based on a configuration specified in the linker configuration file, ILINK places sections in memory. This chapter lists all predefined sections and blocks that are available for the IAR build tools for ARM, and gives detailed reference information about each section. For more information about sections, see the chapter Modules and sections, page 40.
Summary of sections
This table lists the sections and blocks that are used by the IAR build tools:
Section Description
.bss CSTACK .cstart .data .data_init .difunct HEAP .iar.dynexit .intvec IRQ_STACK .noinit .rodata .text
Table 38: Section summary
Holds zero-initialized static and global variables. Holds the stack used by C or C++ programs. Holds the startup code. Holds static and global initialized variables, including the initializers. Holds initializers for.data sections. Holds pointers to code, typically C++ constructors, that should be executed by the system startup code before main is called. Holds the heap used for dynamically allocated data. Holds the atexit table. Holds the reset and interrupt vectors. Holds the stack for interrupt requests, IRQ, and exceptions. Holds __no_init static and global variables. Holds constant data. Holds the program code.
In addition to the ELF sections used for your application, the tools use a number of other ELF sections for a variety of purposes:
319
Sections starting with .debug generally contain debug information in the DWARF format Sections starting with .iar.debug contain supplemental debug information in an IAR format The section .comment contains the tools and command lines used for building the file Sections starting with .rel or .rela contain ELF relocation information The section .symtab contains the symbol table for a file The section .strtab contains the names of the symbol in the symbol table The section .shstrtab contains the names of the sections.
Description describes what type of content the section is holding and, where required, how the section is treated by the linker Memory placement describes memory placement restrictions.
For information about how to allocate sections in memory by modifying the linker configuration file, see the Placing code and datathe linker configuration file, page 42.
.bss
Description Memory placement Holds zero-initialized static and global variables. This section can be placed anywhere in memory.
CSTACK
Description Memory placement See also Block that holds the internal data stack. This block can be placed anywhere in memory. Setting up the stack, page 52.
320
Section reference
.cstart
Description Memory placement Holds the startup code. This section can be placed anywhere in memory.
.data
Description Memory placement Holds static and global initialized variables inlcuding initializers. This section can be placed anywhere in memory.
.data_init
Description Memory placement Holds initializers for .data sections. This section is created by the linker. This section can be placed anywhere in memory.
.difunct
Description Memory placement Holds the dynamic initialization vector used by C++. This section can be placed anywhere in memory.
HEAP
Description Holds the heap used for dynamically allocated data, in other words data allocated by malloc and free, and in C++, new and delete. This section can be placed anywhere in memory. Setting up the heap, page 52.
.iar.dynexit
Description Memory placement Holds the table of calls to be made at exit. This section can be placed anywhere in memory.
321
See also
.intvec
Description Holds the reset vector and exception vectors which contain branch instructions to cstartup, interrupt service routines etc. Must be placed at address range 0x00 to 0x3F.
Memory placement
IRQ_STACK
Description Holds the stack which is used when servicing IRQ exceptions. Other stacks may be added as needed for servicing other exception types: FIQ, SVC, ABT, and UND. The cstartup.s file must be modified to initialize the exception stack pointers used. Note: This section is not used when compiling for Cortex-M. Memory placement See also This section can be placed anywhere in memory. Exception stacks, page 116.
.noinit
Description Memory placement Holds static and global __no_init variables. This section can be placed anywhere in memory.
.rodata
Description Holds constant data. This can include constant variables, string and aggregate literals, etc. This section can be placed anywhere in memory.
Memory placement
.text
Description Memory placement Holds program code, except the code for system initialization. This section can be placed anywhere in memory.
322
IAR utilities
This chapter describes the IAR command line utilities that are available:
The IAR Archive Tooliarchivecreates and manipulates a library (an archive) of several ELF object files The IAR ELF Toolielftoolperforms various transformations on an ELF executable image (such as fill, checksum, format conversions, etc) The IAR ELF Dumper for ARMielfdumparmcreates a text representation of the contents of an ELF relocatable or executable image The IAR ELF Object Tooliobjmanipis used for performing low-level manipulation of ELF object files The IAR Absolute Symbol Exporterisymexportexports absolute symbols from a ROM image file, so that they can be used when you link an add-on application.
INVOCATION SYNTAX
The invocation syntax for the archive builder is:
iarchive parameters
323
Parameters
The parameters are:
Parameter Description
Command line options that define an operation to be performed. Such an option must be specified before the name of the library file. The library file to be operated on. The object file(s) that the specified command operates on. Command line options that define actions to be performed. These options can be placed anywhere on the command line.
Examples
This example creates a library file called mylibrary.a from the source object files module1.o, module.2.o, and module3.o:
iarchive mylibrary.a module1.o module2.o module3.o.
This example replaces module3.o in the library with the content in the module3.o file and appends module4.o to mylibrary.a:
iarchive --replace mylibrary.a module3.o module4.o
Creates a library that contains the listed object files. Deletes the listed object files from the library. Extracts the listed object files from the library. Replaces or appends the listed object files to the library. Lists all symbols defined by files in the library. Lists all files in the library.
For more detailed descriptions, see Descriptions of command line options, page 325.
324
IAR utilities
-f -o --silent, -S --verbose, -V
Table 41: iarchive options summary
Extends the command line. Specifies the library file. Sets silent operation. Reports all performed operations.
-f
Syntax Parameters
-f filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Use this option to make iarchive read command line options from the named file, with the default filename extension xcl. In the command file, you format the items exactly as if they were on the command line itself, except that you can use multiple lines, because the newline character acts just as a space or tab character. Both C and C++ style comments are allowed in the file. Double quotes behave in the same way as in the Microsoft Windows command line environment.
Description
--create
Syntax Parameters
libraryfile The library file that the command operates on. For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. --create libraryfile objectfile1 ... objectfileN
325
objectfile1 ... The object file(s) to build the library from. objectfileN
Description
Use this command to build a new library from a set of object files (modules). The object files are added to the library in the exact order that they are specified on the command line. If no command is specified on the command line, --create is used by default.
--delete, -d
Syntax
--delete libraryfile objectfile1 ... objectfileN -d libraryfile objectfile1 ... objectfileN
Parameters
libraryfile The library file that the command operates on. For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156.
objectfile1 ... The object file(s) that the command operates on. objectfileN
Description
Use this command to remove object files (modules) from an existing library. All object files that are specified on the command line will be removed from the library.
--extract, -x
Syntax
--extract libraryfile [objectfile1 ... objectfileN] -x libraryfile [objectfile1 ... objectfileN]
Parameters
libraryfile The library file that the command operates on. For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156.
objectfile1 ... The object file(s) that the command operates on. objectfileN
326
IAR utilities
Description
Use this command to extract object files (modules) from an existing library. If a list of object files is specified, only these files are extracted. If a list of object files is not specified, all object files in the library are extracted.
-o
Syntax Parameters
-o libraryfile
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. By default, iarchive assumes that the first argument after the iarchive command is the name of the destination library. Use this option to explicitly specify a different filename for the library.
Description
--replace, -r
Syntax
--replace libraryfile objectfile1 ... objectfileN -r libraryfile objectfile1 ... objectfileN
Parameters
libraryfile The library file that the command operates on. For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156.
objectfile1 ... The object file(s) that the command operates on. objectfileN
Description
Use this command to replace or add object files (modules) to an existing library. The object files specified on the command line either replace existing object files in the library (if they have the same name) or are appended to the library.
--silent, -S
Syntax
--silent -S
Description
Use this option to make iarchive operate without sending any messages to the standard output stream.
327
By default, iarchive sends various messages via the standard output stream. You can use this option to prevent this. iarchive sends error and warning messages to the error output stream, so they are displayed regardless of this setting.
--toc, -t
Syntax
--toc libraryfile -t libraryfile
Parameters
libraryfile The library file that the command operates on. For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156.
Description
Use this command to list the names of all object files (modules) in a specified library. In silent mode (--silent), this command performs basic syntax checks on the library file, and displays only errors and warnings.
--symbols
Syntax Parameters
libraryfile The library file that the command operates on. For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. --symbols libraryfile
Description
Use this command to list all external symbols that are defined by any object file (module) in the specified library, together with the name of the object file (module) that defines it. In silent mode (--silent), this command performs symbol table-related syntax checks on the library file and displays only errors and warnings.
--verbose, -V
Syntax
--verbose -V
Description
Use this option to make iarchive report which operations it performs, in addition to giving diagnostic messages.
328
IAR utilities
DIAGNOSTIC MESSAGES
This section lists the messages produced by iarchive:
329
protected.
INVOCATION SYNTAX
The invocation syntax for the IAR ELF Tool is:
ielftool [options] inputfile outputfile [options]
The ielftool tool will first process all the fill options, then it will process all the checksum options (from left to right).
330
IAR utilities
Parameters
The parameters are:
Parameter Description
An absolute ELF executable image produced by the ILINK linker. Any of the available command line options, see Summary of ielftool options, page 331. An absolute ELF executable image.
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156.
Example
This example fills a memory range with 0xFF and then calculates a checksum on the same range:
ielftool my_input.out my_output.out --fill 0xFF;00xFF --checksum __checksum:4,crc32;00xFF
--bin --checksum --fill --ihex --silent --simple --srec --srec-len --srec-s3only --strip --verbose
Sets the format of the output file to binary. Generates a checksum. Specifies fill requirements. Sets the format of the output file to linear Intel hex. Sets silent operation. Sets the format of the output file to Simple code. Sets the format of the output file to Motorola S-records. Restricts the number of data bytes in each S-record. Restricts the S-record output to contain only a subset of records. Removes debug information. Prints all performed operations.
DESCRIPTIONS OF OPTIONS
This section gives detailed reference information about each ielftool option.
331
--bin
Syntax Description
--bin
Sets the format of the output file to binary. To set related options, choose: Project>Options>Output converter
--checksum
Syntax
--checksum {symbol[+offset]|address}:size,algorithm[:flags] [,start];range[;range...]
Parameters
symbol The name of the symbol where the checksum value should be stored. Note that it must exist in the symbol table in the input ELF file. An offset to the symbol. The absolute address where the checksum value should be stored. The number of bytes in the checksum: 1, 2, or 4; must not be larger than the size of the checksum symbol. The checksum algorithm used, one of: sum, a byte-wise calculated arithmetic sum. The result is truncated to 8 bits. sum8wide, a byte-wise calculated arithmetic sum. The result is truncated to the size of the symbol. sum32, a word-wise (32 bits) calculated arithmetic sum crc16, CRC16 (generating polynomial 0x11021); used by default crc32, CRC32 (generating polynomial 0x104C11DB7) crc=n, CRC with a generating polynomial of n. 1 specifies one's complement and 2 specifies two's complement. m reverses the order of the bits within each byte when calculating the checksum. For example, 2m. By default, the initial value of the checksum is 0. If necessary, use start to supply a different initial value. The address range on which the checksum should be calculated. Hexadecimal and decimal notation is allowed (for example, 0x80020x8FFF).
algorithm
flags
start
range
332
IAR utilities
Description
Use this option to calculate a checksum with the specified algorithm for the specified ranges. The checksum will then replace the original value in symbol. A new absolute symbol will be generated; with the symbol name suffixed with _value containing the calculated checksum. This symbol can be used for accessing the checksum value later when needed, for example during debugging. If the --checksum option is used more than once on the command line, the options are evaluated from left to right. If a checksum is calculated for a symbol that is specified in a later evaluated --checksum option, an error is issued. To set related options, choose: Project>Options>Linker>Checksum
--fill
Syntax Parameters
range Specifies the address range for the fill. Hexadecimal and decimal notation is allowed (for example, 0x80020x8FFF). Note that each address must be 4-byte aligned. A hexadecimal string with the 0x prefix (for example, 0xEF) interpreted as a sequence of bytes, where each pair of digits corresponds to one byte (for example 0x123456, for the sequence of bytes 0x12, 0x34, and 0x56). This sequence is repeated over the fill area. If the length of the fill pattern is greater than 1 byte, it is repeated as if it started at address 0. --fill pattern;range[;range...]
pattern
Description
Use this option to fill all gaps in one or more ranges with a pattern, which can be either an expression or a hexadecimal string. The contents will be calculated as if the fill pattern was repeatedly filled from the start address until the end address is passed, and then the real contents will overwrite that pattern. If the --fill option is used more than once on the command line, the fill ranges cannot overlap each other. To set related options, choose: Project>Options>Linker>Checksum
333
--ihex
Syntax Description
--ihex
Sets the format of the output file to linear Intel hex. To set related options, choose: Project>Options>Linker>Output converter
--silent
Syntax Description
--silent
Causes ielftool to operate without sending any messages to the standard output stream. By default, ielftool sends various messages via the standard output stream. You can use this option to prevent this. ielftool sends error and warning messages to the error output stream, so they are displayed regardless of this setting. This option is not available in the IDE.
--simple
Syntax Description
--simple
Sets the format of the output file to Simple code. To set related options, choose: Project>Options>Output converter
--srec
Syntax Description
--srec
Sets the format of the output file to Motorola S-records. To set related options, choose: Project>Options>Output converter
334
IAR utilities
--srec-len
Syntax Parameters
length The number of data bytes in each S-record. --srec-len=length
Description
Restricts the number of data bytes in each S-record. This option can be used in combination with the --srec option. This option is not available in the IDE.
--srec-s3only
Syntax Description
--srec-s3only
Restricts the S-record output to contain only a subset of records, that is S3 and S7 records. This option can be used in combination with the --srec option. This option is not available in the IDE.
--strip
Syntax Description
--strip
Removes debug information from the ELF output file. Note that ielftool needs an unstripped input ELF image. If you use the --strip option in the linker, remove it and use the --strip option in ielftool instead. To set related options, choose: Project>Options>Linker>Output>Include debug information in output
--verbose
Syntax Description
--verbose
Use this option to make ielftool report which operations it performs, in addition to giving diagnostic messages. This option is not available in the IDE because this setting is always enabled.
335
To produce a listing of the general properties of the input file and the ELF segments and ELF sections it contains. This is the default behavior when no command line options are used. To also include a textual representation of the contents of each ELF section in the input file. To specify this behavior, use the command line option --all. To produce a textual representation of selected ELF sections from the input file. To specify this behavior, use the command line option --section.
INVOCATION SYNTAX
The invocation syntax for ielfdumparm is:
ielfdumparm filename
Note: ielfdumparm is a command line tool which is not primarily intended to be used in the IDE.
Parameters
The parameters are:
Parameter Description
filename
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156.
--all -o
Generates output for all input sections regardless of their names or numbers. Specifies an output file.
336
IAR utilities
Description
--raw
Uses the generic hexadecimal/ASCII output format for the contents of any selected section, instead of any dedicated output format for that section. Generates output for selected input sections.
--section/-s
DESCRIPTIONS OF OPTIONS
This section gives detailed reference information about each ielfdumparm option.
--all
Syntax Description
--all
Use this option to include the contents of all ELF sections in the output, in addition to the general properties of the input file. Sections are output in index order, except that each relocation section is output immediately after the section it holds relocations for. By default, no section contents are included in the output.
-o, --output
Syntax
-o {filename|directory} --output {filename|directory}
Parameters
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156. By default, output from the dumper is directed to the console. Use this option to direct the output to a file instead. If you specify a directory, the output file will be named the same as the input file, only with an extra id extension.
Description
337
--section, -s
Syntax
--section section_number|section_name[,...] --s section_number|section_name[,...]
Parameters
section_number section_name The number of the section to be dumped. The name of the section to be dumped.
Description
Use this option to dump the contents of a section with the specified number, or any section with the specified name. If a relocation section is associated with a selected section, its contents are output as well. If you use this option, the general properties of the input file will not be included in the output. You can specify multiple section numbers or names by separating them with commas, or by using this option more than once. By default, no section contents are included in the output.
Example
-s 3,17 -s .debug_frame,42
/* Sections #3 and #17 /* Any sections named .debug_frame and also section #42 */
--raw
Syntax Description
--raw
By default, many ELF sections will be dumped using a text format specific to a particular kind of section. Use this option to dump each selected ELF section using the generic text format. The generic text format dumps each byte in the section in hexadecimal format, and where appropriate, as ASCII text.
338
IAR utilities
INVOCATION SYNTAX
The invocation syntax for the IAR ELF Object Tool is:
iobjmanip options inputfile outputfile
Parameters
The parameters are:
Parameter Description
options
Command line options that define actions to be performed. These options can be placed anywhere on the command line. At least one of the options must be specified. A relocatable ELF object file. A relocatable ELF object file with all the requested operations applied.
inputfile outputfile
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156.
Examples
This example renames the section .example in input.o to .example2 and stores the result in output.o:
iobjmanip --rename_section .example=.example2 input.o output.o
Extends the command line. Removes a section. Renames a section. Renames a symbol. Removes debug information.
339
-f
Syntax Parameters
-f filename
For information about specifying a filename, see Rules for specifying a filename or directory as parameters, page 156. Use this option to make iobjmanip read command line options from the named file, with the default filename extension xcl. In the command file, you format the items exactly as if they were on the command line itself, except that you can use multiple lines, because the newline character acts just as a space or tab character. Both C and C++ style comments are allowed in the file. Double quotes behave in the same way as in the Microsoft Windows command line environment.
Description
--remove_section
Syntax Parameters
section The sectionor sections, if there are more than one section with the same nameto be removed. The number of the section to be removed. Section numbers can be obtained from an object dump created using ielfdumparm. --remove_section {section|number}
number
Description
Use this option to make iobjmanip omit the specified section when generating the output file.
--rename_section
Syntax Parameters
oldname The sectionor sections, if there are more than one section with the same nameto be renamed. The number of the section to be renamed. Section numbers can be obtained from an object dump created using ielfdumparm. The new name of the section. --rename_section {oldname|oldnumber}=newname
oldnumber
newname
340
IAR utilities
Description
Use this option to make iobjmanip rename the specified section when generating the output file.
--rename_symbol
Syntax Parameters
oldname newname The symbol to be renamed. The new name of the symbol. --rename_symbol oldname =newname
Description
Use this option to make iobjmanip rename the specified symbol when generating the output file.
--strip
Syntax Description
--strip
Use this option to remove all sections containing debug information before writing the output file. To set related options, choose: Project>Options>Linker>Output>Include debug information in output
DIAGNOSTIC MESSAGES
This section lists the messages produced by iobjmanip:
341
342
IAR utilities
protected.
INVOCATION SYNTAX
The invocation syntax for the IAR Absolute Symbol Exporter is:
isymexport [options] inputfile outputfile [options]
343
Parameters
The parameters are:
Parameter Description
A ROM image in the form of an executable ELF file (output from linking). Any of the available command line options, see Summary of isymexport options, page 344. A relocatable ELF file that can be used as input to linking, and which contains all or a selection of the absolute symbols in the input file. The output file contains only the symbols, not the actual code or data sections. A steering file can be used to control which symbols that are included, and also to rename some of the symbols if that is desired.
For information about specifying a filename or a directory, see Rules for specifying a filename or directory as parameters, page 156.
--edit -f
Specifies a steering file. Extends the command line; for more information, see -f, page 171.
DESCRIPTIONS OF OPTIONS
This section gives detailed reference information about each isymexport option.
--edit
Syntax Description
--edit steering_file
Use this option to specify a steering file to control what symbols that are included in the isymexport output file, and also to rename some of the symbols if that is desired. Steering files, page 345.
See also
344
IAR utilities
STEERING FILES
A steering file can be used for controlling which symbols that are included, and also to rename some of the symbols if that is desired. In the file, you can use show and hide directives to select which public symbols from the input file that are to be included in the output file. rename directives can be used for changing the names of symbols in the input file.
Syntax
The following syntax rules apply:
Each directive is specified on a separate line. C comments (/*...*/) and C++ comments (//...) can be used. Patterns can contain wildcard characters that match more than one possible character in a symbol name. The * character matches any sequence of zero or more characters in a symbol name. The ? character matches any single character in a symbol name.
Example
rename xxx_* as YYY_* /*Change symbol prefix from xxx_ to YYY_ */ show YYY_* /* Export all symbols from YYY package */ hide *_internal /* But do not export internal symbols */ show zzz? /* Export zzza, but not zzzaaa */ hide zzzx /* But do not export zzzx */
Show directive
Syntax Parameters
pattern A pattern to match against a symbol name. show pattern
Description
A symbol with a name that matches the pattern will be included in the output file unless this is overridden by a later hide directive.
/* Include all public symbols ending in _pub. */ show *_pub
Example
345
Hide directive
Syntax Parameters
pattern A pattern to match against a symbol name. hide pattern
Description
A symbol with a name that matches the pattern will not be included in the output file unless this is overridden by a later show directive.
/* Do not include public symbols ending in _sys. */ hide *_sys
Example
Rename directive
Syntax Parameters
pattern1 A pattern used for finding symbols to be renamed. The pattern can contain no more than one * or ? wildcard character. A pattern used for the new name for a symbol. If the pattern contains a wildcard character, it must be of the same kind as in pattern1. rename pattern1 pattern2
pattern2
Description
Use this directive to rename symbols from the output file to the input file. No exported symbol is allowed to match more than one rename pattern.
rename directives can be placed anywhere in the steering file, but they are executed before any show and hide directives. Thus, if a symbol will be renamed, all show and hide directives in the steering file must refer to the new name.
If the name of a symbol matches a pattern1 pattern that contains no wildcard characters, the symbol will be renamed pattern2 in the output file. If the name of a symbol matches a pattern1 pattern that contains a wildcard character, the symbol will be renamed pattern2 in the output file, with part of the name matching the wildcard character preserved. Example
/* xxx_start will be renamed Y_start_X in the output file, xxx_stop will be renamed Y_stop_X in the output file. */ rename xxx_* Y_*_X
346
IAR utilities
DIAGNOSTIC MESSAGES
This section lists the messages produced by isymexport:
347
This error occurs if the patterns are not the same in this regard.
Es014: ambiguous pattern match: symbol matches more than one rename pattern
A symbol in the input file matches more than one rename pattern.
348
Implementation-defined behavior
This chapter describes how the compiler handles the implementation-defined areas of the C language. ISO 9899:1990, the International Organization for Standardization standard Programming Languages - C (revision and redesign of ANSI X3.159-1989, American National Standard), changed by the ISO Amendment 1:1994, Technical Corrigendum 1, and Technical Corrigendum 2, contains an appendix called Portability Issues. The ISO appendix lists areas of the C language that ISO leaves open to each particular implementation. Note: The compiler adheres to a freestanding implementation of the ISO standard for the C programming language. This means that parts of a standard library can be excluded in the implementation.
Translation
Diagnostics (5.1.1.3)
Diagnostics are produced in the form:
filename,linenumber level[tag]: message
where filename is the name of the source file in which the error was encountered, linenumber is the line number at which the compiler detected the error, level is the level of seriousness of the message (remark, warning, error, or fatal error), tag is a unique tag that identifies the message, and message is an explanatory message, possibly several lines.
349
Environment
Arguments to main (5.1.2.2.2.1)
The function called at program startup is called main. No prototype was declared for main, and the only definition supported for main is:
int main(void)
To change this behavior for the IAR DLIB runtime environment, see Customizing system initialization, page 76.
Identifiers
Significant characters without external linkage (6.1.2)
The number of significant initial characters in an identifier without external linkage is 200.
Characters
Source and execution character sets (5.2.1)
The source character set is the set of legal characters that can appear in source files. The default source character set is the standard ASCII character set. However, if you use the command line option --enable_multibytes, the source character set will be the host computers default character set. The execution character set is the set of legal characters that can appear in the execution environment. The default execution character set is the standard ASCII character set. However, if you use the command line option --enable_multibytes, the execution character set will be the host computers default character set. The IAR DLIB Library needs a multibyte character scanner to support a multibyte execution character set.
350
Implementation-defined behavior
351
Integers
Range of integer values (6.1.2.5)
The representation of integer values are in the two's complement form. The most significant bit holds the sign; 1 for negative, 0 for positive and zero. See Basic data types, page 210, for information about the ranges for the different integer types.
Floating point
Representation of floating-point values (6.1.2.5)
The representation and sets of the various floating-point numbers adheres to IEEE 8541987. A typical floating-point number is built up of a sign-bit (s), a biased exponent (e), and a mantissa (m). See Floating-point types, page 213, for information about the ranges and sizes for the different floating-point types: float and double.
352
Implementation-defined behavior
Registers
Honoring the register keyword (6.5.1)
User requests for register variables are not honored.
353
Qualifiers
Access to volatile objects (6.5.3)
Any reference to an object with volatile qualified type is an access.
Declarators
Maximum numbers of declarators (6.5.4)
The number of declarators is not limited. The number is limited only by the available memory.
Statements
Maximum number of case statements (6.6.4.2)
The number of case statements (case values) in a switch statement is not limited. The number is limited only by the available memory.
Preprocessing directives
Character constants and conditional inclusion (6.8.1)
The character set used in the preprocessor directives is the same as the execution character set. The preprocessor recognizes negative character values if a 'plain' character is treated as a signed character.
354
Implementation-defined behavior
355
keep_definition memory module_name no_pch once __printf_args public_equ __scanf_args STDC system_include vector warnings
356
Implementation-defined behavior
signal() (7.7.1.1)
The signal part of the library is not supported. Note: Low-level interface functions exist in the library, but will not perform anything. Use the template source code to implement application-specific signal handling. See Signal and raise, page 84.
Files (7.9.3)
Whether a write operation on a text stream causes the associated file to be truncated beyond that point, depends on the application-specific implementation of the low-level file routines. See File input and output, page 80.
remove() (7.9.4.1)
The effect of a remove operation on an open file depends on the application-specific implementation of the low-level file routines. See File input and output, page 80.
rename() (7.9.4.2)
The effect of renaming a file to an already existing filename depends on the application-specific implementation of the low-level file routines. See File input and output, page 80.
357
%p in printf() (7.9.6.1)
The argument to a %p conversion specifier, print pointer, to printf() is treated as having the type void *. The value will be printed as a hexadecimal number, similar to using the %x conversion specifier.
%p in scanf() (7.9.6.2)
The %p conversion specifier, scan pointer, to scanf() reads a hexadecimal number and converts it into a value with the type void *.
Environment (7.10.4.4)
The set of available environment names and the method for altering the environment list is described in Environment interaction, page 83.
358
Implementation-defined behavior
system() (7.10.4.5)
How the command processor works depends on how you have implemented the system function. See Environment interaction, page 83.
no error domain error range error file positioning error multi-byte encoding error unknown error error nnn
clock() (7.12.2.1)
From where the system clock starts counting depends on how you have implemented the clock function. See Time, page 85.
359
360
Glossary
Glossary
This is a general glossary for terms relevant to embedded systems programming. Some of the terms do not apply to the IAR Embedded Workbench version that you are using.
Assembler options Parameters you can specify to change the default behavior of the assembler. Assembler language A machine-specific set of mnemonics used to specify operations to the target processor and input or output registers or data areas. Assembler language might sometimes be preferred over C/C++ to save memory or to enhance the execution speed of the application. Attributes See Section attributes. Auto variables The term refers to the fact that each time the function in which the variable is declared is called, a new instance of the variable is created automatically. This can be compared with the behavior of local variables in systems using static overlay, where a local variable only exists in one instance, even if the function is called recursively. Also called local variables. Compare Register variables.
A
Absolute location A specific memory address for an object specified in the source code, as opposed to the object being assigned a location by the IAR ILINK Linker. Address expression An expression which has an address as its value. AEABI Embedded Application Binary Interface for ARM, defined by ARM Limited. Application The program developed by the user of the IAR Systems toolkit and which will be run as an embedded application on a target processor. Ar The GNU binary utility for creating, modifying, and extracting from archives, that is, libraries. See also Iarchive. Architecture A term used by computer designers to designate the structure of complex information-processing systems. It includes the kinds of instructions and data used, the memory organization and addressing, and the methods by which the system is implemented. The two main architecture types used in processor design are Harvard architecture and von Neumann architecture. Archive See Library. Assembler directives The set of commands that control how the assembler operates.
B
Backtrace Information that allows the IAR C-SPY Debugger to show, without any runtime penalty, the complete stack of function calls wherever the program counter is, provided that the code comes from compiled C functions. Bank See Memory bank. Bank switching Switching between different sets of memory banks. This software technique increases a computer's usable memory by allowing different pieces of memory to occupy the same address space. Banked code Code that is distributed over several banks of memory. Each function must reside in only one bank.
361
Banked data Data that is distributed over several banks of memory. Each data object must fit inside one memory bank. Banked memory Has multiple storage locations for the same address. See also Memory bank. Bank-switching routines Code that selects a memory bank. Batch files A text file containing operating system commands which are executed by the command line interpreter. In Unix, this is called a shell script because it is the Unix shell which includes the command line interpreter. Batch files can be used as a simple way to combine existing commands into new commands. Bitfield A group of bits considered as a unit. Block, in linker configuration file A continuous piece of code or data. It is either built up of blocks, overlays, and sections or it is empty. A block has a name, and the start and end address of the block can be referred to from the application. It can have attributes such as a maximum size, a specific size, or a minimum alignment. The contents can have a specific order or not. Breakpoint 1. Code breakpoint. A point in a program that, when reached, triggers some special behavior useful to the process of debugging. Generally, breakpoints are used for stopping program execution or dumping the values of some or all of the program variables. Breakpoints can be part of the program itself, or they can be set by the programmer as part of an interactive session with a debugging tool for scrutinizing the program's execution. 2. Data breakpoint. A point in memory that, when accessed, triggers some special behavior useful to the process of debugging. Generally, data breakpoints are used to stop program execution when an address location is accessed either by a read operation or a write operation.
3. Immediate breakpoint. A point in memory that, when accessed, trigger some special behavior useful in the process of debugging. Immediate breakpoints are generally used for halting the program execution in the middle of a memory access instruction (before or after the actual memory access depending on the access type) while performing some user-specified action. The execution is then resumed. This feature is only available in the simulator version of C-SPY.
C
Calling convention A calling convention describes the way one function in a program calls another function. This includes how register parameters are handled, how the return value is returned, and which registers that will be preserved by the called function. The compiler handles this automatically for all C and C++ functions. All code written in assembler language must conform to the rules in the calling convention to be callable from C or C++, or to be able to call C and C++ functions. The C calling convention and the C++ calling conventions are not necessarily the same. Cheap As in cheap memory access. A cheap memory access either requires few cycles to perform, or few bytes of code to implement. A cheap memory access is said to have a low cost. See Memory access cost. Checksum A computed value which depends on the ROM content of the whole or parts of the application, and which is stored along with the application to detect corruption of the data. The checksum is produced by the linker to be verified with the application. Several algorithms are supported. Compare CRC (cyclic redundancy checking). Code banking See Banked code.
362
Glossary
Code model The code model controls how code is generated for an application. Typically, the code model controls behavior such as how functions are called and in which code section functions will be located. All object files of an application must be compiled using the same code model. Code pointers A code pointer is a function pointer. As many cores allow several different methods of calling a function, compilers for embedded systems usually provide the users with the ability to use all these methods. Do not confuse code pointers with data pointers. Code sections Read-only sections that contain code. See also Section. Compilation unit See Translation unit. Compiler options Parameters you can specify to change the default behavior of the compiler. Configuration See ILINK configuration, and Linker configuration file. Cost See Memory access cost. CRC (cyclic redundancy checking) A number derived from, and stored with, a block of data to detect corruption. A CRC is based on polynomials and is a more advanced way of detecting errors than a simple arithmetic checksum. Compare Checksum. C-SPY options Parameters you can specify to change the default behavior of the IAR C-SPY Debugger. Cstartup Code that sets up the system before the application starts executing.
C-style preprocessor A preprocessor is either a stand-alone application or an integrated part of a compiler, that performs preprocessing of the input stream before the actual compilation occurs. A C-style preprocessor follows the rules set up in the ANSI specification of the C language and implements commands like #define, #if, and #include, which are used to handle textual macro substitution, conditional compilation, and inclusion of other files.
D
Data banking See Banked data. Data model The data model specifies the default memory type. This means that the data model typically controls one or more of the following: The method used and the code generated to access static and global variables, dynamically allocated data, and the runtime stack. It also controls the default pointer type and in which data sections static and global variables will be located. A project can only use one data model at a time, and the same model must be used by all user modules and all library modules in the project. Data pointers Many cores have different addressing modes to access different memory types or address spaces. Compilers for embedded systems usually have a set of different data pointer types so they can access the available memory efficiently. Data representation How different data types are laid out in memory and what value ranges they represent. Declaration A specification to the compiler that an object, a variable or function, exists. The object itself must be defined in exactly one translation unit (source file). An object must either be declared or defined before it is used. Normally an object that is used in many files is defined in one source file. A declaration is normally placed in a header file that is included by the files that use the object.
363
For example:
/* Variable "a" exists somewhere. Function "b" takes two int parameters and returns an int. */ extern int a; int b(int, int);
Disassembly window A C-SPY window that shows the memory contents disassembled as machine instructions, interspersed with the corresponding C source code (if available). DWARF An industry-standard debugging format which supports source level debugging. This is the format used by the IAR ILINK Linker for representing debug information in an object. Dynamic initialization Variables in a program written in C are initialized during the initial phase of execution, before the main function is called. These variables are always initialized with a static value, which is determined either at compile time or at link time. This is called static initialization. In C++, variables might require initialization to be performed by executing code, for example, running the constructor of global objects, or performing dynamic memory allocation. Dynamic memory allocation There are two main strategies for storing variables: statically at link time, or dynamically at runtime. Dynamic memory allocation is often performed from the heap and it is the size of the heap that determines how much memory that can be used for dynamic objects and variables. The advantage of dynamic memory allocation is that several variables or objects that are not active at the same time can be stored in the same memory, thus reducing the memory requirements of an application. See also Heap memory. Dynamic object An object that is allocated, created, destroyed, and released at runtime. Dynamic objects are almost always stored in memory that is dynamically allocated. Compare Static object.
Definition The variable or function itself. Only one definition can exist for each variable or function in an application. See also Tentative definition. For example:
int a; int b(int x, int y) { return x + y; }
Demangling To restore a mangled name to the more common C/C++ name. See also Mangling. Derivative One of two or more processor variants in a series or family of microprocessors or microcontrollers. Device description file A file used by C-SPY that contains various device-specific information such as I/O registers (SFR) definitions, interrupt vectors, and control register definitions. Device driver Software that provides a high-level programming interface to a particular peripheral device. Digital signal processor (DSP) A device that is similar to a microprocessor, except that the internal CPU is optimized for use in applications involving discrete-time signal processing. In addition to standard microprocessor instructions, digital signal processors usually support a set of complex instructions to perform common signal-processing computations quickly.
E
EEPROM Electrically Erasable, Programmable Read-Only Memory. A type of ROM that can be erased electronically, and then be re-programmed.
364
Glossary
ELF Executable and Linking Format, an industry-standard object file format. This is the format used by the IAR ILINK Linker. The debug information is formatted using DWARF. EPROM Erasable, Programmable Read-Only Memory. A type of ROM that can be erased by exposing it to ultraviolet light, and then be re-programmed. Embedded C++ A subset of the C++ programming language, which is intended for embedded systems programming. The fact that performance and portability are particularly important in embedded systems development was considered when defining the language. Embedded system A combination of hardware and software, designed for a specific purpose. Embedded systems are often part of a larger system or product. Emulator An emulator is a hardware device that performs emulation of one or more derivatives of a processor family. An emulator can often be used instead of the actual core and connects directly to the printed circuit boardwhere the core would have been connectedvia a connecting device. An emulator always behaves exactly as the processor it emulates, and is used when debugging requires all systems actuators, or when debugging device drivers. Enea OSE Load module format A specific ELF format that is loadable by the OSE operating system. See also ELF. Enumeration A type which includes in its definition an exhaustive list of possible values for variables of that type. Common examples include Boolean, which takes values from the list [true, false], and day-of-week which takes values [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]. Enumerated types are a feature of typed languages, including C and Ada.
Characters, (fixed-size) integers, and even floating-point types might be (but are not usually) considered to be (large) enumerated types. Executable image Contains the executable image; the result of linking several relocatable object files and libraries. The file format used for an object file is ELF with embedded DWARF for debug information. Exceptions An exception is an interrupt initiated by the processor hardware, or hardware that is tightly coupled with the processor, for instance, a memory management unit (MMU). The exception signals a violation of the rules of the architecture (access to protected memory), or an extreme error condition (division by zero). Do not confuse this use of the word exception with the term exception used in the C++ language (but not in Embedded C++). Expensive As in expensive memory access. An expensive memory access either requires many cycles to perform, or many bytes of code to implement. An expensive memory access is said to have a high cost. See Memory access cost. Extended keywords Non-standard keywords in C and C++. These usually control the definition and declaration of objects (that is, data and functions). See also Keywords.
F
Filling How to fill up byteswith a specific fill patternthat exists between the sections in an executable image. These bytes exist because of the alignment demands on the sections.
365
Format specifiers Used to specify the format of strings sent by library functions such as printf. In the following example, the function call contains one format string with one format specifier, %c, that prints the value of a as a single ASCII character:
printf("a = %c", a);
Host The computer that communicates with the target processor. The term is used to distinguish the computer on which the debugger is running from the core the embedded application you develop runs on.
G
General options Parameters you can specify to change the default behavior of all tools that are included in the IDE. Generic pointers Pointers that have the ability to point to all different memory types in, for example, a core based on the Harvard architecture.
I
Iarchive The IAR Systems utility for creating archives, that is, libraries. Iarchive is delivered with IAR Embedded Workbench. IDE (integrated development environment) A programming environment with all necessary tools integrated into one single application. Ielfdumparm The IAR Systems utility for creating a text representation of the contents of ELF relocatable or executable image. Ielftool The IAR Systems utility for performing various transformations on an ELF executable image, such as fill, checksum, and format conversion. ILINK The IAR ILINK Linker which produces absolute output in the ELF/DWARF format. ILINK configuration The definition of available physical memories and the placement of sectionspieces of code and datainto those memories. ILINK requires a configuration to build an executable image. Image See Executable image. Include file A text file which is included into a source file. This is often done by the preprocessor.
H
Harvard architecture A core based on the Harvard architecture has separate data and instruction buses. This allows execution to occur in parallel. As an instruction is being fetched, the current instruction is executing on the data bus. Once the current instruction is complete, the next instruction is ready to go. This theoretically allows for much faster execution than a von Neumann architecture, but adds some silicon complexity. Compare von Neumann architecture. Heap memory The heap is a pool of memory in a system that is reserved for dynamic memory allocation. An application can request parts of the heap for its own use; once memory is allocated from the heap it remains valid until it is explicitly released back to the heap by the application. This type of memory is useful when the number of objects is not known until the application executes. Note that this type of memory is risky to use in systems with a limited amount of memory or systems that are expected to run for a very long time. Heap size Total size of memory that can be dynamically allocated.
366
Glossary
Initialization setup in linker configuration file Defines how to initialize RAM sections with their initializers. Normally, only non-constant non-noinit variables are initialized but, for example, pieces of code can be initialized as well. Initialized sections Read-write sections that should be initialized with specific values at startup. See also Section. Inline assembler Assembler language code that is inserted directly between C statements. Inlining An optimization that replaces function calls with the body of the called function. This optimization increases the execution speed and can even reduce the size of the generated code. Instruction mnemonics A word or acronym used in assembler language to represent a machine instruction. Different processors have different instruction sets and therefore use a different set of mnemonics to represent them, such as, ADD, BR (branch), BLT (branch if less than), MOVE, LDR (load register). Interrupt vector A small piece of code that will be executed, or a pointer that points to code that will be executed when an interrupt occurs. Interrupt vector table A table containing interrupt vectors, indexed by interrupt type. This table contains the processor's mapping between interrupts and interrupt service routines and must be initialized by the programmer. Interrupts In embedded systems, the use of interrupts is a method of detecting external events immediately, for example a timer overflow or the pressing of a button.
Interrupts are asynchronous events that suspend normal processing and temporarily divert the flow of control through an interrupt handler routine. Interrupts can be caused by both hardware (I/O, timer, machine check) and software (supervisor, system call or trap instruction). Compare Trap. Intrinsic An adjective describing native compiler objects, properties, events, and methods. Intrinsic functions 1. Function calls that are directly expanded into specific sequences of machine code. 2. Functions called by the compiler for internal purposes (that is, floating point arithmetic etc.). Iobjmanip The IAR Systems utility for performing low-level manipulation of ELF object files.
K
Key bindings Key shortcuts for menu commands used in the IDE. Keywords A fixed set of symbols built into the syntax of a programming language. All keywords used in a language are reservedthey cannot be used as identifiers (in other words, user-defined objects such as variables or procedures). See also Extended keywords.
L
L-value A value that can be found on the left side of an assignment and thus be changed. This includes plain variables and de-referenced pointers. Expressions like (x + 10) cannot be assigned a new value and are therefore not L-values. Language extensions Target-specific extensions to the C language.
367
Library See Runtime library. Library configuration file A file that contains a configuration of the runtime library. The file contains information about what functionality is part of the runtime environment. The file is used for tailoring a build of a runtime library. See also Runtime library. Linker configuration file A file that contains a configuration used by ILINK when building an executable image. See also ILINK configuration. Local variable See Auto variables. Location counter See Program location counter (PLC). Logical address See Virtual address (logical address).
2. C macro. A text substitution mechanism used during preprocessing of source files. Macros are defined using the #define preprocessing directive. The replacement text of each macro is then substituted for any occurrences of the macro name in the rest of the translation unit. 3. C-SPY macros are programs that you can write to enhance the functionality of C-SPY. A typical application of C-SPY macros is to associate them with breakpoints; when such a breakpoint is hit, the macro is run and can for example be used to simulate peripheral devices, to evaluate complex conditions, or to output a trace. The C-SPY macro language is like a simple dialect of C, but is less strict with types. Mailbox A mailbox in an RTOS is a point of communication between two or more tasks. One task can send messages to another task by placing the message in the mailbox of the other task. Mailboxes are also known as message queues or message ports. Mangling Mangling is a technique used for mapping a complex C/C++ name into a simple name. Both mangled and unmangled names can be produced for C/C++ symbols in ILINK messages. Memory, in linker configuration file A physical memory. The number of units it contains and how many bits a unit consists of, are defined in the linker configuration file. The memory is always addressable from 0x0 to size -1. Memory access cost The cost of a memory access can be in clock cycles, or in the number of bytes of code needed to perform the access. A memory which requires large instructions or many instructions is said to have a higher access cost than a memory which can be accessed with few, or small instructions. Memory area A region of the memory.
M
MAC (Multiply and accumulate) A special instruction, or on-chip device, that performs a multiplication together with an addition. This is very useful when performing signal processing where many filters and transforms have the form:
The accumulator of the MAC usually has a higher precision (more bits) than normal registers. See also Digital signal processor (DSP). Macro 1. Assembler macros are user-defined sets of assembler lines that can be expanded later in the source file by referring to the given macro name. Parameters will be substituted if referred to.
368
Glossary
Memory bank The smallest unit of continuous memory in banked memory. One memory bank at a time is visible in a cores physical address space. Memory map A map of the different memory areas available to the core. Memory model Specifies the memory hierarchy and how much memory the system can handle. Your application must use only one memory model at a time, and the same model must be used by all user modules and all library modules. Microcontroller A microprocessor on a single integrated circuit intended to operate as an embedded system. In addition to a CPU, a microcontroller typically includes small amounts of RAM, PROM, timers, and I/O ports. Microprocessor A CPU contained on one (or a few) integrated circuits. A single-chip microprocessor can include other components such as memory, memory management, caches, floating-point unit, I/O ports and timers. Such devices are also known as microcontrollers. Multi-file compilation A technique which means that the compiler compiles several source files as one compilation unit, which enables for interprocedural optimizations such as inlining, cross call, and cross jump on multiple source files in a compilation unit. Module An object. An object file contains a module and library contains one or more objects. The basic unit of linking. A module contains definitions for symbols (exports) and references to external symbols (imports). When you compile C/C++, each translation unit produces one module.
N
Nested interrupts A system where an interrupt can be interrupted by another interrupt is said to have nested interrupts. Non-banked memory Has a single storage location for each memory address in a cores physical address space. Non-initialized memory Memory that can contain any value at reset, or in the case of a soft reset, can remember the value it had before the reset. No-init sections Read-write sections that should not be initialized at startup. See also Section. Non-volatile storage Memory devices such as battery-backed RAM, ROM, magnetic tape and magnetic disks that can retain data when electric power is shut off. Compare Volatile storage. NOP No operation. This is an instruction that does not do anything, but is used to create a delay. In pipelined architectures, the NOP instruction can be used for synchronizing the pipeline. See also Pipeline.
O
Objcopy A GNU binary utility for converting an absolute object file in ELF format into an absolute object file, for example the format Motorola-std or Intel-std. See also Ielftool. Object An object file or a library member. Object file, absolute See Executable image.
369
Object file, relocatable The result of compiling or assembling a source file. The file format used for an object file is ELF with embedded DWARF for debug information. Operator A symbol used as a function, with infix syntax if it has two arguments (+, for example) or prefix syntax if it has only one (for instance, bitwise negation, ~). Many languages use operators for built-in functions such as arithmetic and logic. Operator precedence Each operator has a precedence number assigned to it that determines the order in which the operator and its operands are evaluated. The highest precedence operators are evaluated first. Use parentheses to group operators and operands to control the order in which the expressions are evaluated. Output image The resulting application after linking. This term is equivalent to executable image, which is the term used in the IAR Systems user documentation. Overlay, in linker configuration file Like a block, but it contains several overlaid entities, each built up of blocks, overlays, and sections. The size of an overlay is determined by its largest constituent.
Placement, in linker configuration file How to place blocks, overlays, and sections into a region. It determines how pieces of code and data are actually placed in the available physical memory. Pointer An object that contains an address to another object of a specified type. #pragma During compilation of a C/C++ program, the #pragma preprocessing directive causes the compiler to behave in an implementation-defined manner. This can include, for example, producing output on the console, changing the declaration of a subsequent object, changing the optimization level, or enabling/disabling language extensions. Pre-emptive multitasking An RTOS task is allowed to run until a higher priority process is activated. The higher priority task might become active as the result of an interrupt. The term preemptive indicates that although a task is allotted to run a given length of time (a timeslice), it might lose the processor at any time. Each time an interrupt occurs, the task scheduler looks for the highest priority task that is active and switches to that task. If the located task is different from the task that was executing before the interrupt, the previous task is suspended at the point of interruption. Compare Round Robin. Preprocessing directives A set of directives that are executed before the parsing of the actual code is started. Preprocessor See C-style preprocessor. Processor variant The different chip setups that the compiler supports. See Derivative. Program counter (PC) A special processor register that is used to address instructions. Compare Program location counter (PLC).
P
Parameter passing See Calling convention. Peripheral unit A hardware component other than the processor, for example memory or an I/O device. Pipeline A structure that consists of a sequence of stages through which a computation flows. New operations can be initiated at the start of the pipeline even though other operations are already in progress through the pipeline.
370
Glossary
Program location counter (PLC) Used in the IAR Assembler to denote the code address of the current instruction. The PLC is represented by a special symbol (typically $) that can be used in arithmetic expressions. Also called simply location counter (LC). PROM Programmable Read-Only Memory. A type of ROM that can be programmed only once. Project The user application development project. Project options General options that apply to an entire project, for example the target processor that the application will run on.
Real-time system A computer system whose processes are time-sensitive. Compare Real-time operating system (RTOS). Region, in linker configuration file A set of non-overlapping ranges. The ranges can lie in one or more memories. Blocks, overlays, and sections are placed into regions in the linker configuration file. Region expression, in linker configuration file A region built up from region literals, regions, and the common set operations possible in the linker configuration file. Region literal, in linker configuration file A literal that defines a set of one or more non-overlapping ranges in a memory. Register constant A register constant is a value that is loaded into a dedicated processor register when the system is initialized. The compiler can then generate code that assumes that the constants are present in the dedicated registers. Register A small on-chip memory unit, usually just one or a few bytes in size, which is particularly efficient to access and therefore often reserved as a temporary storage area during program execution. Register locking Register locking means that the compiler can be instructed that some processor registers shall not be used during normal code generation. This is useful in many situations. For example, some parts of a system might be written in assembler language to gain speed. These parts might be given dedicated processor registers. Or the register might be used by an operating system, or by other third-party software. Register variables Typically, register variables are local variables that are placed in registers instead of on the (stack) frame of the function. Register variables are much more efficient than other variables because they do not require memory accesses, so the compiler can use shorter/faster instructions when working with them. See also Auto variables.
Q
Qualifiers See Type qualifiers.
R
Range, in linker configuration file A range of consecutive addresses in a memory. A region is built up of ranges. R-value A value that can be found on the right side of an assignment. This is just a plain value. See also L-value. Read-only sections Sections that contain code or constants. See also Section. Real-time operating system (RTOS) An operating system which guarantees the latency between an interrupt being triggered and the interrupt handler starting, and how tasks are scheduled. An RTOS is typically much smaller than a normal desktop operating system. Compare Real-time system.
371
Relay A synonym to veneer, see Veneer. Relocatable sections Sections that have no fixed location in memory before linking. Reset A reset is a restart from the initial state of a system. A reset can originate from hardware (hard reset), or from software (soft reset). A hard reset can usually not be distinguished from the power-on condition, which a soft reset can be. ROM-monitor A piece of embedded software designed specifically for use as a debugging tool. It resides in the ROM of the evaluation board chip and communicates with a debugger via a serial port or network connection. The ROM-monitor provides a set of primitive commands to view and modify memory locations and registers, create and remove breakpoints, and execute your application. The debugger combines these primitives to fulfill higher-level requests like program download and single-step. Round Robin Task scheduling in an operating system, where all tasks have the same priority level and are executed in turn, one after the other. Compare Pre-emptive multitasking. RTOS See Real-time operating system (RTOS). Runtime library A collection of relocatable object files that will be included in the executable image only if referred to from an object file, in other words conditionally linked. Runtime model attributes A mechanism that is designed to prevent modules that are not compatible to be linked into an application. ILINK uses the runtime model attributes when automatically choosing library to verify that the correct one is used.
S
Saturation arithmetics Most, if not all, C and C++ implementations use mod2N 2-complement-based arithmetics where an overflow wraps the value in the value domain, that is, (127 + 1) = -128. Saturation arithmetics, on the other hand, does not allow wrapping in the value domain, for instance, (127 + 1) = 127, if 127 is the upper limit. Saturation arithmetics is often used in signal processing, where an overflow condition would have been fatal if value wrapping had been allowed. Scheduler The part of an RTOS that performs task-switching. It is also responsible for selecting which task that should be allowed to run. Many scheduling algorithms exist, but most of them are either based on static scheduling (performed at compile-time), or on dynamic scheduling (where the actual choice of which task to run next is taken at runtime, depending on the state of the system at the time of the task-switch). Most real-time systems use static scheduling, because it makes it possible to prove that the system will not violate the real-time requirements. Scope The section of an application where a function or a variable can be referenced by name. The scope of an item can be limited to file, function, or block. Section An entity that either contains data or text. Typically, one or more variables, or functions. A section is the smallest linkable unit. Section attributes Each section has a name and an attribute. The attribute defines what a section contains, that is, if the section content is read-only, read/write, code, data, etc. Section fragment A part of a section, typically a variable or a function.
372
Glossary
Section selection In the linker configuration file, defining a set of sections by using section selectors. A section belongs to the most restrictive section selector if it can be part of more than one selection. Three different selectors can be used individually or in conjunction to select the set of sections: section attribute (selecting by the section content), section name (selecting by the section name), and object name (selecting from a specific object). Semaphore A semaphore is a type of flag that is used for guaranteeing exclusive access to resources. The resource can be a hardware port, a configuration memory, or a set of variables. If several tasks must access the same resource, the parts of the code (the critical sections) that access the resource must be made exclusive for every task. This is done by obtaining the semaphore that protects that resource, thus blocking all other tasks from it. If another task wishes to use the resource, it also must obtain the semaphore. If the semaphore is already in use, the second task must wait until the semaphore is released. After the semaphore is released, the second task is allowed to execute and can obtain the semaphore for its own exclusive access. Severity level The level of seriousness of the diagnostic response from the assembler, compiler, or debugger, when it notices that something is wrong. Typical severity levels are remarks, warnings, errors, and fatal errors. A remark just points to a possible problem, while a fatal error means that the programming tool exits without finishing. Sharing A physical memory that can be addressed in several ways; defined in the linker configuration file. Short addressing Many cores have special addressing modes for efficient access to internal RAM and memory mapped I/O. Short addressing is therefore provided as an extended feature by many compilers for embedded systems. See also Data pointers.
Side effect An expression in C or C++ is said to have a side-effect if it changes the state of the system. Examples are assignments to a variable, or using a variable with the post-increment operator. The C and C++ standards state that a variable that is subject to a side-effect should not be used more that once in an expression. As an example, this statement violates that rule:
*d++ = *d;
Signal Signals provide event-based communication between tasks. A task can wait for one or more signals from other tasks. Once a task receives a signal it waits for, execution continues. A task in an RTOS that waits for a signal does not use any processing time, which allows other tasks to execute. Simulator A debugging tool that runs on the host and behaves as similar to the target processor as possible. A simulator is used to debug the application when the hardware is unavailable, or not needed for proper debugging. A simulator is usually not connected to any physical peripheral devices. A simulated processor is often slower, or even much slower, than the real hardware. Single stepping Executing one instruction or one C statement at a time in the debugger. Skeleton code An incomplete code framework that allows the user to specialize the code. Special function register (SFR) A register that is used to read and write to the hardware components of the core. Stack frames Data structures containing data objects like preserved registers, local variables, and other data objects that must be stored temporary for a particular scope (usually a function).
373
Earlier compilers usually had a fixed size and layout on a stack frame throughout a complete function, while modern compilers might have a very dynamic layout and size that can change anywhere and anytime in a function. Standard libraries The C and C++ library functions as specified by the C and C++ standard, and support routines for the compiler, like floating-point routines. Statically allocated memory This kind of memory is allocated once and for all at link-time, and remains valid all through the execution of the application. Variables that are either global or declared static are allocated this way. Static object An object whose memory is allocated at link-time and is created during system startup (or at first use). Compare Dynamic object. Static overlay Instead of using a dynamic allocation scheme for parameters and auto variables, the linker allocates space for parameters and auto variables at link time. This generates a worst-case scenario of stack usage, but might be preferable for small chips with expensive stack access or no stack access at all. Structure value A collecting names for structs and unions. A struct is a collection of data object placed sequentially in memory (possibly with pad bytes between them). A union is a collection of data sharing the same memory location. Symbol 1. A name that represents a register, an absolute value, or a memory address (relative or absolute). 2. A configuration symbol that can be referred to from the executable image. The symbol is defined to be used in the linker configuration file and it has a constant value. Symbolic location A location that uses a symbolic name because the exact address is unknown.
T
Target 1. An architecture. 2. A piece of hardware. The particular embedded system you are developing the application for. The term is usually used to distinguish the system from the host system. Task (thread) A task is an execution thread in a system. Systems that contain many tasks that execute in parallel are called multitasking systems. Because a processor only executes one instruction stream at the time, most systems implement some sort of task-switch mechanism (often called context switch) so that all tasks get their share of processing time. The process of determining which task that should be allowed to run next is called scheduling. Two common scheduling methods are Pre-emptive multitasking and Round Robin. Tentative definition A variable that can be defined in multiple files, provided that the definition is identical and that it is an absolute variable. Terminal I/O A simulated terminal window in C-SPY. Timeslice The (longest) time an RTOS allows a task to run without running the task-scheduling algorithm. A task might be allowed to execute during several consecutive timeslices before being switched out. A task might also not be allowed to use its entire time slice, for example if, in a preemptive system, a higher priority task is activated by an interrupt. Timer A peripheral that counts independent of the program execution. Translation unit A source file together with all the header files and source files included via the preprocessor directive #include, except for the lines skipped by conditional preprocessor directives such as #if and #ifdef.
374
Glossary
Trap A trap is an interrupt initiated by inserting a special instruction into the instruction stream. Many systems use traps to call operating system functions. Another name for trap is software interrupt. Type qualifiers In standard C/C++, const or volatile. IAR Systems compilers usually add target-specific type qualifiers for memory and other type attributes.
Volatile storage Data stored in a volatile storage device is not retained when the power to the device is turned off. To preserve data during a power-down cycle, you should store it in non-volatile storage. This should not be confused with the C keyword volatile. Compare Non-volatile storage. von Neumann architecture A computer architecture where both instructions and data are transferred over a common data channel. Compare Harvard architecture.
U
UBROF (Universal Binary Relocatable Object Format) File format produced by some of the IAR Systems programming tools, however, not by these tools.
W
Watchpoints Watchpoints keep track of the values of C variables or expressions in the C-SPY Watch window as the application is being executed.
V
Value expressions, in linker configuration file A constant number that can be built up out of expressions that has a syntax similar to C expressions. Veneer A small piece of code that is inserted as a springboard between caller and callee when: There is a mismatch in mode, for example ARM and Thumb The call instruction does not reach its destination. Virtual address (logical address) An address that must be translated by the compiler, linker or the runtime system into a physical memory address before it is used. The virtual address is the address seen by the application, which can be different from the address seen by other parts of the system. Virtual space An IAR Embedded Workbench Editor feature which allows you to place the insertion point outside of the area where there are actual characters.
X
XLINK The IAR XLINK Linker which uses the UBROF output format.
Z
Zero-initialized sections Sections that should be initialized to zero at startup. See also Section. Zero-overhead loop A loop in which the loop condition, including branching back to the beginning of the loop, does not take any time at all. This is usually implemented as a special hardware feature of the processor and is not available in all architectures.
375
Zone Different processors have widely differing memory architectures. Zone is the term C-SPY uses for a named memory area. For example, on processors with separately addressable code and data memory there would be at least two zones. A processor with an intricate banked memory scheme might have several zones.
376
Index
Index A
--aapcs (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 161 ABI, AEABI and IA64 . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 abort implementation-defined behavior (DLIB) . . . . . . . . . . 358 system termination (DLIB) . . . . . . . . . . . . . . . . . . . . . . 75 Abort_Handler (exception function) . . . . . . . . . . . . . . . . . . 32 absolute location data, placing at (@) . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 language support for . . . . . . . . . . . . . . . . . . . . . . . . . . 222 #pragma location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 address expression, definition of . . . . . . . . . . . . . . . . . . . . 361 AEABI definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 support for in IAR build tools . . . . . . . . . . . . . . . . . . . 123 --aeabi (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 161 _AEABI_PORTABILITY_LEVEL (preprocessor symbol) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 _AEABI_PORTABLE (preprocessor symbol) . . . . . . . . . 125 algorithm (STL header file) . . . . . . . . . . . . . . . . . . . . . . . 293 alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 forcing stricter (#pragma data_alignment) . . . . . . . . . . 247 in structures (#pragma pack) . . . . . . . . . . . . . . . . . . . . 254 in structures, causing problems . . . . . . . . . . . . . . . . . . 129 of an object (__ALIGNOF__) . . . . . . . . . . . . . . . . . . . 223 of data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 restrictions for inline assembler . . . . . . . . . . . . . . . . . . . 94 alignment (pragma directive) . . . . . . . . . . . . . . . . . . . . . . 355 __ALIGNOF__ (operator) . . . . . . . . . . . . . . . . . . . . . . . . 223 --align_sp_on_irq (compiler option) . . . . . . . . . . . . . . . . . 161 --all (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 anonymous structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 anonymous symbols, creating . . . . . . . . . . . . . . . . . . . . . . 226 application definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 startup and termination (DLIB) . . . . . . . . . . . . . . . . . . . 72 architecture definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 more information about . . . . . . . . . . . . . . . . . . . . . . . xxix of ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 archive, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 ARM and Thumb code, overview . . . . . . . . . . . . . . . . . . . . . . 29 CPU mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 memory layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 supported devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 --arm (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . 162 __arm (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 237 __ARMVFP__ (predefined symbol) . . . . . . . . . . . . . . . . . 284 __ARM4M__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM4TM__ (predefined symbol) . . . . . . . . . . . . . . . . 284 __ARM5__ (predefined symbol) . . . . . . . . . . . . . . . . . . . 284 __ARM5E__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM6__ (predefined symbol) . . . . . . . . . . . . . . . . . . . 284 __ARM6M__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM6SM__ (predefined symbol). . . . . . . . . . . . . . . . . 284 __ARM7M__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM7R__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 arrays designated initializers in . . . . . . . . . . . . . . . . . . . . . . . 227 implementation-defined behavior. . . . . . . . . . . . . . . . . 353 incomplete at end of structs . . . . . . . . . . . . . . . . . . . . . 226 non-lvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 of incomplete types . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 single-value initialization . . . . . . . . . . . . . . . . . . . . . . . 230 ar, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 asm, __asm (language extension) . . . . . . . . . . . . . . . . . . . 225 assembler code calling from C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 calling from C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 inserting inline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 assembler directives definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 for call frame information . . . . . . . . . . . . . . . . . . . . . . 103 using in inline assembler code . . . . . . . . . . . . . . . . . . . . 94
377
assembler instructions inserting inline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 assembler labels, making public (--public_equ) . . . . . . . . 184 assembler language interface . . . . . . . . . . . . . . . . . . . . . . . 91 calling convention. See assembler code assembler language, definition of . . . . . . . . . . . . . . . . . . . 361 assembler list file, generating . . . . . . . . . . . . . . . . . . . . . . 173 assembler options, definition of . . . . . . . . . . . . . . . . . . . . 361 assembler output file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 assembler, inline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 asserts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 implementation-defined behavior of, (DLIB) . . . . . . . . 356 including in application . . . . . . . . . . . . . . . . . . . . . . . . 287 assert.h (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 atexit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 reserving space for calls . . . . . . . . . . . . . . . . . . . . . . . . . 53 atexit limit, setting up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 atoll, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 attributes object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 attributes on sections, definition of . . . . . . . . . . . . . . . . . . 372 auto variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 at function entrance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 programming hints for efficient code . . . . . . . . . . . . . . 139 using in inline assembler code . . . . . . . . . . . . . . . . . . . . 94 auto, packing algorithm for initializers . . . . . . . . . . . . . . . 306
B
backtrace information definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 backtrace information See call frame information bank switching, definition of. . . . . . . . . . . . . . . . . . . . . . . 361 banked code, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 361 banked data, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 362 banked memory, definition of . . . . . . . . . . . . . . . . . . . . . . 362 bank-switching routines, definition of. . . . . . . . . . . . . . . . 362 Barr, Michael . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii
baseaddr (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . 355 __BASE_FILE__ (predefined symbol) . . . . . . . . . . . . . . . 284 basic type names, using in preprocessor expressions (--migration_preprocessor_extensions) . . . . . . . . . . . . . . . 175 basic_template_matching (pragma directive) . . . . . . . . . . 355 batch files definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 error return codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 none for building library from command line . . . . . . . . 71 --BE8 (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 --BE32 (linker option). . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 big-endian (byte order) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 __big_endian (extended keyword) . . . . . . . . . . . . . . . . . . 237 --bin (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 binary streams (DLIB) . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 bit negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 bitfields data representation of . . . . . . . . . . . . . . . . . . . . . . . . . . 212 hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 implementation-defined behavior of . . . . . . . . . . . . . . 353 non-standard types in . . . . . . . . . . . . . . . . . . . . . . . . . . 223 bitfields (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 246 bitfield, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 Block, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 bold style, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii bool (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 adding support for in DLIB . . . . . . . . . . . . . . . . . 291, 294 making available in C code . . . . . . . . . . . . . . . . . . . . . 295 breakpoints, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 362 bubble sort function, defined in stdlib.h . . . . . . . . . . . . . . 296 building_runtime (pragma directive) . . . . . . . . . . . . . . . . . 355 __BUILD_NUMBER__ (predefined symbol) . . . . . . . . . 284 Burrows-Wheeler algorithm, for packing initializers . . . . 306 BusFault_Handler (exception function) . . . . . . . . . . . . . . . 36 bwt, packing algorithm for initializers . . . . . . . . . . . . . . . 306 byte order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 identifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 specifying (--endian) . . . . . . . . . . . . . . . . . . . . . . . . . . 170
378
Index
C
C and C++ linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 C/C++ calling convention. See calling convention C header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 call frame information . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 in assembler list file . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 in assembler list file (-lA) . . . . . . . . . . . . . . . . . . . . . . 174 call stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 callee-save registers, stored on stack . . . . . . . . . . . . . . . . . . 26 calling convention C++, requiring C linkage . . . . . . . . . . . . . . . . . . . . . . . . 96 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 in compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 calloc (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 See also heap implementation-defined behavior of (DLIB) . . . . . . . . 358 can_instantiate (pragma directive) . . . . . . . . . . . . . . . . . . 355 cassert (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 293 cast operators in Extended EC++ . . . . . . . . . . . . . . . . . . . . . . . . 108, 111 missing from Embedded C++ . . . . . . . . . . . . . . . . . . . 108 casting of pointers and integers . . . . . . . . . . . . . . . . . . . . . . . . 215 pointers to integers, language extension . . . . . . . . . . . . 229 cctype (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 293 cerrno (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 293 cexit (system termination code) in DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 CFI (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . . 103 cfiCommon.i (CFI header example file) . . . . . . . . . . . . . . 106 CFI_COMMON_ARM (CFI macro) . . . . . . . . . . . . . . . . 106 CFI_COMMON_Thumb (CFI macro) . . . . . . . . . . . . . . . 106 CFI_NAME_BLOCK (CFI macro). . . . . . . . . . . . . . . . . . 106 cfloat (DLIB header file). . . . . . . . . . . . . . . . . . . . . . . . . . 293 char (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 changing default representation (--char_is_signed) . . . 162 signed and unsigned . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 characters, implementation-defined behavior of . . . . . . . . 350
character-based I/O in DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 overriding in runtime library . . . . . . . . . . . . . . . . . . . . . 69 --char_is_signed (compiler option) . . . . . . . . . . . . . . . . . . 162 cheap memory access, definition of . . . . . . . . . . . . . . . . . 362 checksum calculation of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362 display format in C-SPY for symbol . . . . . . . . . . . . . . 122 --checksum (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . 332 cinttypes (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . 293 classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 climits (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 294 clocale (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . 294 clock (DLIB library function), implementation-defined behavior of . . . . . . . . . . . . . . . . . 359 clock.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 __close (DLIB library function) . . . . . . . . . . . . . . . . . . . . . 81 clustering (compiler transformation) . . . . . . . . . . . . . . . . . 138 disabling (--no_clustering) . . . . . . . . . . . . . . . . . . . . . . 176 __CLZ (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 262 cmain (system initialization code) in DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 cmath (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 294 code ARM and Thumb, overview. . . . . . . . . . . . . . . . . . . . . . 29 banked, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 361 interruption of execution . . . . . . . . . . . . . . . . . . . . . . . . 31 skeleton, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 373 code model, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 363 code motion (compiler transformation) . . . . . . . . . . . . . . . 137 disabling (--no_code_motion) . . . . . . . . . . . . . . . . . . . 176 code pointers, definition of . . . . . . . . . . . . . . . . . . . . . . . . 363 code sections, definition of . . . . . . . . . . . . . . . . . . . . . . . . 363 codeseg (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 355 command line options part of compiler invocation syntax . . . . . . . . . . . . . . . . 147 part of linker invocation syntax . . . . . . . . . . . . . . . . . . 147 passing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 See also compiler options
379
See also linker options typographic convention . . . . . . . . . . . . . . . . . . . . . . xxxiii command prompt icon, in this guide . . . . . . . . . . . . . . . xxxiii commands, iarchive. .comment (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . 320 comments after preprocessor directives. . . . . . . . . . . . . . . . . . . . . 230 C++ style, using in C code . . . . . . . . . . . . . . . . . . . . . . 225 common block (call frame information) . . . . . . . . . . . . . . 103 common subexpr elimination (compiler transformation) . 137 disabling (--no_cse) . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 compilation date exact time of (__TIME__) . . . . . . . . . . . . . . . . . . . . . . 285 identifying (__DATE__) . . . . . . . . . . . . . . . . . . . . . . . 284 compiler environment variables . . . . . . . . . . . . . . . . . . . . . . . . . 148 invocation syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 output from . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 compiler listing, generating (-l). . . . . . . . . . . . . . . . . . . . . 173 compiler object file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 including debug information in (--debug, -r) . . . . . . . . 164 output from compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 150 compiler optimization levels . . . . . . . . . . . . . . . . . . . . . . . 135 compiler options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 passing to compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 reading from file (-f) . . . . . . . . . . . . . . . . . . . . . . . . . . 171 specifying parameters . . . . . . . . . . . . . . . . . . . . . . . . . 157 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 for creating skeleton code . . . . . . . . . . . . . . . . . . . . . . . 95 instruction scheduling . . . . . . . . . . . . . . . . . . . . . . . . . 139 --warnings_affect_exit_code . . . . . . . . . . . . . . . . . . . . 151 compiler platform, identifying . . . . . . . . . . . . . . . . . . . . . 285 compiler transformations . . . . . . . . . . . . . . . . . . . . . . . . . 134 compiler version number . . . . . . . . . . . . . . . . . . . . . . . . . 286 compiling from the command line . . . . . . . . . . . . . . . . . . . . . . . . . 19 syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
complex numbers, supported in Embedded C++ . . . . . . . . 108 complex (library header file) . . . . . . . . . . . . . . . . . . . . . . . 292 compound literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 computer style, typographic convention . . . . . . . . . . . . xxxiii --config (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 --config_def (linker option). . . . . . . . . . . . . . . . . . . . . . . . 192 configuration basic project settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 __low_level_init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 configuration file for linker See also linker configuration file definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 configuration symbols definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 for file input and output . . . . . . . . . . . . . . . . . . . . . . . . . 80 for locale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 for printf and scanf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 for strtod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 in library configuration files . . . . . . . . . . . . . . . . . . . . . . 71 in linker configuration files . . . . . . . . . . . . . . . . . . . . . 314 specifying for linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 consistency, module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 const declaring objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 non-top level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 const_cast (cast operator) . . . . . . . . . . . . . . . . . . . . . . . . . 108 contents, of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxx conventions, used in this guide . . . . . . . . . . . . . . . . . . . xxxiii copyright notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii __CORE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 284 core identifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 selecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Cortex special considerations for interrupt functions . . . . . . . . . 36 support for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 cost. See memory access cost __cplusplus (predefined symbol) . . . . . . . . . . . . . . . . . . . 284 --cpp_init_routine (linker option) . . . . . . . . . . . . . . . . . . . 193
380
Index
--cpu (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 --cpu (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 CPU modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 specifying on command line . . . . . . . . . . . . . . . . . . . . 162 CPU variant, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 364 CPU, specifying on command line . . . . . . . . . . . . . . . . . . 193 __CPU_MODE__ (predefined symbol) . . . . . . . . . . . . . . 284 --cpu_mode (compiler option) . . . . . . . . . . . . . . . . . . . . . 163 CRC, definition of. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 --create (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . 325 csetjmp (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . 294 csignal (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . 294 cspy_support (pragma directive) . . . . . . . . . . . . . . . . . . . . 355 CSTACK (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 See also stack .cstart (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 cstartup (system startup code) customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 overriding in runtime library . . . . . . . . . . . . . . . . . . . . . 69 cstartup.s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 cstdarg (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . 294 cstdbool (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . 294 cstddef (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . 294 cstdio (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 294 cstdlib (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 294 cstring (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . 294 ctime (DLIB header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 294 ctype.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 added C functionality . . . . . . . . . . . . . . . . . . . . . . . . . . 295 cwctype.h (library header file) . . . . . . . . . . . . . . . . . . . . . 294 C++ See also Embedded C++ and Extended Embedded C++ absolute location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 calling convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 features excluded from EC++ . . . . . . . . . . . . . . . . . . . 107 header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 language extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
special function types. . . . . . . . . . . . . . . . . . . . . . . . . . . 36 static member variables . . . . . . . . . . . . . . . . . . . . . . . . 133 support for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 C++ terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii C++-style comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 C-SPY interface to system termination . . . . . . . . . . . . . . . . . . . 76 STL container support . . . . . . . . . . . . . . . . . . . . . . . . . 111 C-SPY options, definition of . . . . . . . . . . . . . . . . . . . . . . . 363 C-style preprocessor, definition of . . . . . . . . . . . . . . . . . . 363 C_INCLUDE (environment variable) . . . . . . . . . . . . 148149 C99 standard, added functionality from . . . . . . . . . . . . . . 294
D
-D (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 -d (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 data alignment of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 different ways of storing . . . . . . . . . . . . . . . . . . . . . . . . 25 located, declaring extern . . . . . . . . . . . . . . . . . . . . . . . 132 placing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131, 186, 319 at absolute location . . . . . . . . . . . . . . . . . . . . . . . . . 132 representation of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 data block (call frame information) . . . . . . . . . . . . . . . . . . 104 data model, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 363 data pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 data representation, definition of . . . . . . . . . . . . . . . . . . . . 363 data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 floating point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 data_alignment (pragma directive) . . . . . . . . . . . . . . . . . . 247 __DATE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 284 date (library function), configuring support for . . . . . . . . . . 85 DC32 (assembler directive). . . . . . . . . . . . . . . . . . . . . . . . . 94 --debug (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 164
381
debug information, including in object file . . . . . . . . 164, 185 .debug (ELF section). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 debugger, low-level interface . . . . . . . . . . . . . . . . . . . . . . . 86 DebugMon_Handler (exception function). . . . . . . . . . . . . . 36 declarations empty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 in for loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 Kernighan & Ritchie . . . . . . . . . . . . . . . . . . . . . . . . . . 141 of functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 declarations and statements, mixing . . . . . . . . . . . . . . . . . 225 declaration, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 363 declarators, implementation-defined behavior . . . . . . . . . 354 define block (linker directive) . . . . . . . . . . . . . . . . . . . . . . 303 define overlay (linker directive) . . . . . . . . . . . . . . . . . . . . 304 define symbol (linker directive) . . . . . . . . . . . . . . . . . . . . 314 --define_symbol (linker option) . . . . . . . . . . . . . . . . . . . . 193 define_type_info (pragma directive) . . . . . . . . . . . . . . . . . 355 definition, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 --delete (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . 326 delete (keyword) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 demangling, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 364 denormalized numbers. See subnormal numbers --dependencies (compiler option) . . . . . . . . . . . . . . . . . . . 165 deque (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 293 derivative, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 destructors and interrupts, using . . . . . . . . . . . . . . . . . . . . 112 device description files definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 preconfigured . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 device driver, definition of . . . . . . . . . . . . . . . . . . . . . . . . 364 diagnostic messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 classifying as compilation errors . . . . . . . . . . . . . . . . . 166 classifying as compilation remarks . . . . . . . . . . . . . . . 166 classifying as compiler warnings . . . . . . . . . . . . . . . . . 167 classifying as errors . . . . . . . . . . . . . . . . . . . . . . . 177, 200 classifying as linker warnings . . . . . . . . . . . . . . . . . . . 195 classifying as linking errors . . . . . . . . . . . . . . . . . . . . . 194 classifying as linking remarks . . . . . . . . . . . . . . . . . . . 194 disabling compiler warnings . . . . . . . . . . . . . . . . . . . . 181
disabling linker warnings . . . . . . . . . . . . . . . . . . . . . . . 202 disabling wrapping of in compiler . . . . . . . . . . . . . . . . 181 disabling wrapping of in linker . . . . . . . . . . . . . . . . . . 202 enabling compiler remarks . . . . . . . . . . . . . . . . . . . . . . 185 enabling linker remarks . . . . . . . . . . . . . . . . . . . . . . . . 205 listing all used by compiler . . . . . . . . . . . . . . . . . . . . . 167 listing all used by linker . . . . . . . . . . . . . . . . . . . . . . . . 196 suppressing in compiler . . . . . . . . . . . . . . . . . . . . . . . . 167 suppressing in linker . . . . . . . . . . . . . . . . . . . . . . . . . . 195 diagnostics iarchive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 iobjmanip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 isymexport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 --diagnostics_tables (compiler option) . . . . . . . . . . . . . . . 167 --diagnostics_tables (linker option) . . . . . . . . . . . . . . . . . . 196 diag_default (pragma directive) . . . . . . . . . . . . . . . . . . . . 248 --diag_error (compiler option) . . . . . . . . . . . . . . . . . . . . . 166 --diag_error (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 194 --no_fragments (compiler option) . . . . . . . . . . . . . . . . . . . 177 --no_fragments (linker option) . . . . . . . . . . . . . . . . . . . . . 200 diag_error (pragma directive) . . . . . . . . . . . . . . . . . . . . . . 248 --diag_remark (compiler option) . . . . . . . . . . . . . . . . . . . . 166 --diag_remark (linker option) . . . . . . . . . . . . . . . . . . . . . . 194 diag_remark (pragma directive) . . . . . . . . . . . . . . . . . . . . 248 --diag_suppress (compiler option) . . . . . . . . . . . . . . . . . . 167 --diag_suppress (linker option) . . . . . . . . . . . . . . . . . . . . . 195 diag_suppress (pragma directive) . . . . . . . . . . . . . . . . . . . 249 --diag_warning (compiler option) . . . . . . . . . . . . . . . . . . . 167 --diag_warning (linker option) . . . . . . . . . . . . . . . . . . . . . 195 diag_warning (pragma directive) . . . . . . . . . . . . . . . . . . . 249 DIFUNCT (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 digital signal processor, definition of . . . . . . . . . . . . . . . . 364 directives pragma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 245 to the linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 directory, specifying as parameter . . . . . . . . . . . . . . . . . . . 156 __disable_fiq (intrinsic function) . . . . . . . . . . . . . . . . . . . 262 __disable_interrupt (intrinsic function) . . . . . . . . . . . . . . . 263 __disable_irq (intrinsic function) . . . . . . . . . . . . . . . . . . . 263
382
Index
Disassembly window, definition of . . . . . . . . . . . . . . . . . . 364 --discard_unused_publics (compiler option) . . . . . . . . . . . 168 disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii DLIB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 290 building customized library . . . . . . . . . . . . . . . . . . . . . . 63 configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 configuring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 168 reference information. See the online help system . . . . 289 runtime environment . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 --dlib_config (compiler option). . . . . . . . . . . . . . . . . . . . . 168 DLib_Config_Full.h (library configuration file) . . . . . . . . . 71 DLib_Config_Normal.h (library configuration file) . . . . . . 71 DLib_Defaults.h (library configuration file) . . . . . . . . . . . . 71 __DLIB_FILE_DESCRIPTOR (configuration symbol) . . . 80 __DMB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 263 do not initialize (linker directive) . . . . . . . . . . . . . . . . . . . 308 document conventions. . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii documentation, library . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 domain errors, implementation-defined behavior . . . . . . . 356 double (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 double_t, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 295 do_not_instantiate (pragma directive) . . . . . . . . . . . . . . . . 355 __DSB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 263 DSP. See digital signal processor DWARF, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 dynamic initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 dynamic memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 dynamic memory allocation, definition of . . . . . . . . . . . . 364 dynamic object, definition of . . . . . . . . . . . . . . . . . . . . . . 364
E
-e (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 early_initialization (pragma directive) . . . . . . . . . . . . . . . 355 --ec++ (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . 169 EC++ header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 --edit (isymexport option) . . . . . . . . . . . . . . . . . . . . . . . . . 344 edition, of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
--eec++ (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 169 EEPROM, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 ELF, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 Embedded C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 differences from C++ . . . . . . . . . . . . . . . . . . . . . . . . . . 107 enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 function linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 language extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Embedded C++ Technical Committee . . . . . . . . . . . . . xxxiii embedded systems, IAR special support for . . . . . . . . . . . . . 6 embedded system, definition of . . . . . . . . . . . . . . . . . . . . 365 __embedded_cplusplus (predefined symbol) . . . . . . . . . . 284 empty region (in linker configuration file) . . . . . . . . . . . . 302 emulator (C-SPY driver), definition of . . . . . . . . . . . . . . . 365 __enable_fiq (intrinsic function) . . . . . . . . . . . . . . . . . . . . 264 --enable_hardware_workaround (compiler option) . . . . . . 170 __enable_interrupt (intrinsic function) . . . . . . . . . . . . . . . 264 __enable_irq (intrinsic function) . . . . . . . . . . . . . . . . . . . . 264 --enable_multibytes (compiler option) . . . . . . . . . . . . . . . 170 --endian (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . 170 Enea OSE load module format, definition of . . . . . . . . . . 365 --entry (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 entry label, program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 enumerations, implementation-defined behavior. . . . . . . . 353 enumeration, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 365 enums data representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 forward declarations of . . . . . . . . . . . . . . . . . . . . . . . . 229 --enum_is_int (compiler option) . . . . . . . . . . . . . . . . . . . . 171 environment implementation-defined behavior. . . . . . . . . . . . . . . . . 350 runtime (DLIB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 environment variables C_INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148149 ILINKARM_CMD_LINE . . . . . . . . . . . . . . . . . . . . . . 149 QCCARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 EPROM, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
383
EQU (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . . 184 ERANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 errno.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 classifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177, 200 classifying for compiler . . . . . . . . . . . . . . . . . . . . . . . . 166 classifying for linker . . . . . . . . . . . . . . . . . . . . . . . . . . 194 range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 error return codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 --error_limit (compiler option) . . . . . . . . . . . . . . . . . . . . . 171 --error_limit (linker option) . . . . . . . . . . . . . . . . . . . . . . . 196 exception handling, missing from Embedded C++ . . . . . . 107 exception stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 exception (library header file) . . . . . . . . . . . . . . . . . . . . . . 292 exceptions, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 365 executable image, definition of . . . . . . . . . . . . . . . . . . . . . 365 _Exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 implementation-defined behavior. . . . . . . . . . . . . . . . . 358 _exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 __exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 expensive memory access, definition of . . . . . . . . . . . . . . 365 export keyword, missing from Extended EC++ . . . . . . . . 110 export (linker directive). . . . . . . . . . . . . . . . . . . . . . . . . . . 315 --export_builtin_config (linker option) . . . . . . . . . . . . . . . 197 expressions (in linker configuration file) . . . . . . . . . . . . . . 315 extended command line file for compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 for linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 passing options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Extended Embedded C++ . . . . . . . . . . . . . . . . . . . . . . . . . 108 enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 standard template library (STL) . . . . . . . . . . . . . . . . . . 293 extended keywords . . . . . . . . . . . . . . . . . . . . . . . . . . 233, 323 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 enabling (-e) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
syntax object attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 type attributes on data objects . . . . . . . . . . . . . . . . . 234 type attributes on data pointers . . . . . . . . . . . . . . . . 234 type attributes on functions . . . . . . . . . . . . . . . . . . . 234 extended-selectors (in linker configuration file) . . . . . . . . 313 extern "C" linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 --extract (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . 326
F
-f (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 -f (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 -f (iobjmanip option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340 -f (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 fast interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 fatal error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 fgetpos (library function), implementation-defined behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 __FILE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 284 file dependencies, tracking . . . . . . . . . . . . . . . . . . . . . . . . 165 file paths, specifying for #include files . . . . . . . . . . . . . . . 173 filename extension for device description files . . . . . . . . . . . . . . . . 6 extension for header files . . . . . . . . . . . . . . . . . . . . . . . . . 6 of object executable image . . . . . . . . . . . . . . . . . . . . . . 203 search procedure for. . . . . . . . . . . . . . . . . . . . . . . . . . . 149 specifying as parameter . . . . . . . . . . . . . . . . . . . . . . . . 156 --fill (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 filling, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 __fiq (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . . 237 FIQ_Handler (exception function) . . . . . . . . . . . . . . . . . . . 32 float (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 floating-point constants hexadecimal notation . . . . . . . . . . . . . . . . . . . . . . . . . . 227 hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 floating-point expressions, using in preprocessor extensions . . . . . . . . . . . . . . . . . . . . 175
384
Index
floating-point format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 implementation-defined behavior. . . . . . . . . . . . . . . . . 352 special cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 32-bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 64-bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 floating-point unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 float.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 float_t, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 fmod (library function), implementation-defined behavior . . . . . . . . . . . . . . . . . . . 357 for loops, declarations in . . . . . . . . . . . . . . . . . . . . . . . . . . 225 --force_output (linker option) . . . . . . . . . . . . . . . . . . . . . . 197 format specifiers, definition of . . . . . . . . . . . . . . . . . . . . . 366 formats floating-point values . . . . . . . . . . . . . . . . . . . . . . . . . . 213 standard IEEE (floating point) . . . . . . . . . . . . . . . . . . . 213 fpclassify, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . 295 --fpu (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 FP_INFINITE, C99 extension . . . . . . . . . . . . . . . . . . . . . 295 FP_NAN, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 295 FP_NORMAL, C99 extension . . . . . . . . . . . . . . . . . . . . . 295 FP_SUBNORMAL, C99 extension . . . . . . . . . . . . . . . . . 295 FP_ZERO, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . 295 fragmentation, of heap memory . . . . . . . . . . . . . . . . . . . . . 27 free (library function). See also heap . . . . . . . . . . . . . . . . . 27 fstream (library header file) . . . . . . . . . . . . . . . . . . . . . . . 292 fstream.h (library header file) . . . . . . . . . . . . . . . . . . . . . . 292 ftell (library function), implementation-defined behavior . 358 Full DLIB (library configuration) . . . . . . . . . . . . . . . . . . . . 63 __func__ (predefined symbol) . . . . . . . . . . . . . . . . . 231, 285 __FUNCTION__ (predefined symbol) . . . . . . . . . . . 231, 285 function calls calling convention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 stack image after . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 function declarations, Kernighan & Ritchie . . . . . . . . . . . 141 function execution, in RAM . . . . . . . . . . . . . . . . . . . . . . . . 30 function inlining (compiler transformation) . . . . . . . . . . . 137 disabling (--no_inline) . . . . . . . . . . . . . . . . . . . . . . . . . 178 function pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
function prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 enforcing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 function (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 355 functional (STL header file) . . . . . . . . . . . . . . . . . . . . . . . 293 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 C++ and special function types . . . . . . . . . . . . . . . . . . . 36 declaring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 140 inlining. . . . . . . . . . . . . . . . . . . . . . . . . 137, 139, 225, 250 interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 intrinsic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91, 140 intrinsic, definition of. . . . . . . . . . . . . . . . . . . . . . . . . . 367 parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 placing in memory . . . . . . . . . . . . . . . . . . . . 131, 133, 186 recursive avoiding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 storing data on stack . . . . . . . . . . . . . . . . . . . . . . 2627 reentrancy (DLIB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 related extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 return values from . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 special function types. . . . . . . . . . . . . . . . . . . . . . . . . . . 30
G
general options, definition of . . . . . . . . . . . . . . . . . . . . . . 366 generic pointers, definition of . . . . . . . . . . . . . . . . . . . . . . 366 getenv (library function), configuring support for . . . . . . . . 83 getzone (library function), configuring support for . . . . . . . 85 getzone.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 __get_BASEPRI (intrinsic function) . . . . . . . . . . . . . . . . . 264 __get_CONTROL (intrinsic function) . . . . . . . . . . . . . . . 264 __get_CPSR (intrinsic function) . . . . . . . . . . . . . . . . . . . . 265 __get_FAULTMASK (intrinsic function) . . . . . . . . . . . . . 265 __get_interrupt_state (intrinsic function) . . . . . . . . . . . . . 265 __get_PRIMASK (intrinsic function) . . . . . . . . . . . . . . . . 265 glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361 GRP_COMDAT, group type . . . . . . . . . . . . . . . . . . . . . . . 342 guidelines, reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix
385
H
Harbison, Samuel P. . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii HardFault_Handler (exception function). . . . . . . . . . . . . . . 36 hardware support in compiler . . . . . . . . . . . . . . . . . . . . . . . 62 Harvard architecture, definition of . . . . . . . . . . . . . . . . . . 366 hash_map (STL header file) . . . . . . . . . . . . . . . . . . . . . . . 293 hash_set (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . 293 hdrstop (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 355 header files C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 EC++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 special function registers . . . . . . . . . . . . . . . . . . . . . . . 142 STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 DLib_Config_Full.h. . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 DLib_Config_Normal.h . . . . . . . . . . . . . . . . . . . . . . . . . 71 DLib_Defaults.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 intrinsics.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 stdbool.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211, 291 stddef.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 --header_context (compiler option) . . . . . . . . . . . . . . . . . . 172 heap dynamic memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 storing data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 heap memory, definition of . . . . . . . . . . . . . . . . . . . . . . . . 366 heap size and standard I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 changing default. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 HEAP (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117, 321 hide (isymexport directive) . . . . . . . . . . . . . . . . . . . . . . . . 346 hints for good code generation . . . . . . . . . . . . . . . . . . . . . . . 139 using efficient data types . . . . . . . . . . . . . . . . . . . . . . . 127 host, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 HUGE_VALF, C99 extension . . . . . . . . . . . . . . . . . . . . . . 295 HUGE_VALL, C99 extension. . . . . . . . . . . . . . . . . . . . . . 295
I
-I (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 IAR Command Line Build Utility. . . . . . . . . . . . . . . . . . . . 71 IAR Systems Technical Support . . . . . . . . . . . . . . . . . . . . 154 iarbuild.exe (utility) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 iarchive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 commands summary . . . . . . . . . . . . . . . . . . . . . . . . . . 324 options summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 .iar.debug (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .iar.dynexit (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 __IAR_SYSTEMS_ICC__ (predefined symbol) . . . . . . . 285 IA64 ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 __ICCARM__ (predefined symbol) . . . . . . . . . . . . . . . . . 285 icons, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii IDE building a library from . . . . . . . . . . . . . . . . . . . . . . . . . . 71 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 overview of build tools. . . . . . . . . . . . . . . . . . . . . . . . . . . 3 identifiers, implementation-defined behavior . . . . . . . . . . 350 IEEE format, floating-point values . . . . . . . . . . . . . . . . . . 213 ielfdump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 options summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 ielftool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 options summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 if (linker directive) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 --ihex (ielftool option). . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 ILINK definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 See linker ILINK options. See linker options ILINKARM_CMD_LINE (environment variable) . . . . . . 149 --image_input (linker option) . . . . . . . . . . . . . . . . . . . . . . 198 implementation-defined behavior . . . . . . . . . . . . . . . . . . . 349 important_typedef (pragma directive) . . . . . . . . . . . . . . . . 355 include files definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 including before source files . . . . . . . . . . . . . . . . . . . . 183
386
Index
specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 include (linker directive) . . . . . . . . . . . . . . . . . . . . . . . . . . 318 include_alias (pragma directive) . . . . . . . . . . . . . . . . . . . . 249 infinity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 INFINITY, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . 295 inheritance, in Embedded C++ . . . . . . . . . . . . . . . . . . . . . 107 initialization changing default. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 dynamic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 packing algorithm for . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 single-value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 initialization in ILINK config file, definition of . . . . . . . . 367 initialize (linker directive) . . . . . . . . . . . . . . . . . . . . . . . . . 305 initialized sections, definition of . . . . . . . . . . . . . . . . . . . . 367 initializers, static . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 inline assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93, 225 avoiding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 See also assembler language interface inline functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 in compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 inline (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . . . 250 inlining, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 instantiate (pragma directive) . . . . . . . . . . . . . . . . . . . . . . 355 instruction mnemonics, definition of. . . . . . . . . . . . . . . . . 367 instruction scheduling (compiler option). . . . . . . . . . . . . . 139 integer characteristics, adding . . . . . . . . . . . . . . . . . . . . . . 295 integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 implementation-defined behavior. . . . . . . . . . . . . . . . . 352 intptr_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 ptrdiff_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 size_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 uintptr_t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 integral promotion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Integrated Development Environment (IDE) definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Intel hex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Intel IA64 ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
internal error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 interrupt functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 fast interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 in ARM Cortex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 nested interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 software interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 interrupt state, restoring . . . . . . . . . . . . . . . . . . . . . . . . . . 273 interrupt vector definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 interrupt vector table definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 .intvec section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 interrupts definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 nested, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 processor state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 using with EC++ destructors . . . . . . . . . . . . . . . . . . . . 112 --interwork (compiler option) . . . . . . . . . . . . . . . . . . . . . . 173 __interwork (extended keyword) . . . . . . . . . . . . . . . . . . . 238 interworking code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 intptr_t (integer type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 __intrinsic (extended keyword) . . . . . . . . . . . . . . . . . . . . . 238 intrinsic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 intrinsics.h (header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 259 intrinsic, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 introduction linker configuration file . . . . . . . . . . . . . . . . . . . . . . . . 297 linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 inttypes.h (library header file) . . . . . . . . . . . . . . . . . . . . . . 291 inttypes.h, added C functionality . . . . . . . . . . . . . . . . . . . 295 .intvec (section). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 invocation syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 iobjmanip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 options summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
387
iomanip (library header file) . . . . . . . . . . . . . . . . . . . . . . . 292 iomanip.h (library header file) . . . . . . . . . . . . . . . . . . . . . 292 ios (library header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 iosfwd (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 292 iostream (library header file) . . . . . . . . . . . . . . . . . . . . . . . 292 iostream.h (library header file) . . . . . . . . . . . . . . . . . . . . . 292 __irq (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . . 238 IRQ_Handler (exception function) . . . . . . . . . . . . . . . . . . . 32 IRQ_STACK (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 __ISB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . . 266 isblank, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 isfinite, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 isgreater, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 295 isinf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 islessequal, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . 295 islessgreater, C99 extension . . . . . . . . . . . . . . . . . . . . . . . 295 isless, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 isnan, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 isnormal, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 295 ISO/ANSI C compiler extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 C++ features excluded from EC++ . . . . . . . . . . . . . . . 107 specifying strict usage . . . . . . . . . . . . . . . . . . . . . . . . . 187 iso646.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 istream (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 292 isunordered, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . 295 iswblank, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 296 isymexport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 options summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344 italic style, in this guide . . . . . . . . . . . . . . . . . . . . . . . . xxxiii iterator (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . 293 I/O debugging, support for . . . . . . . . . . . . . . . . . . . . . . . . . 86 I/O module, overriding in runtime library . . . . . . . . . . . . . . 69
Kernighan & Ritchie function declarations . . . . . . . . . . . . 141 disallowing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 Kernighan, Brian W. . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii key bindings, definition of . . . . . . . . . . . . . . . . . . . . . . . . 367 keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 extended, overview of . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
L
-l (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 for creating skeleton code . . . . . . . . . . . . . . . . . . . . . . . 95 labels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 assembler, making public . . . . . . . . . . . . . . . . . . . . . . . 184 __program_start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Labrosse, Jean J. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii Lajoie, Jose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii language extensions definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 Embedded C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 enabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 enabling (-e) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 language overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 language (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . 251 __LDC (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 266 __LDCL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 266 __LDCL_noidx (intrinsic function) . . . . . . . . . . . . . . . . . 266 __LDC_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . . 266 __LDC2 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 266 __LDC2L (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 266 __LDC2L_noidx (intrinsic function) . . . . . . . . . . . . . . . . 266 __LDC2_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . 266 __LDREX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 267 --legacy (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . 174 Lempel-Ziv-Welch algorithm, for packing initializers . . . 306 libraries building DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 runtime. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
K
--keep (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 keep (linker directive) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 keep_definition (pragma directive) . . . . . . . . . . . . . . . . . . 356
388
Index
standard template library . . . . . . . . . . . . . . . . . . . . . . . 293 library configuration file definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 library configuration files DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 DLib_Defaults.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 for Normal and Full . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 modifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 library documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 library features, missing from Embedded C++ . . . . . . . . . 108 library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 reference information . . . . . . . . . . . . . . . . . . . . . . . . . xxxii summary, DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 library header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 library modules introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 overriding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 library object files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 library options, setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 library project template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 library, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 lightbulb icon, in this guide . . . . . . . . . . . . . . . . . . . . . . xxxiv limits.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 __LINE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 285 linkage, C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 linker. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 output from . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 linker configuration file definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 for placing code and data . . . . . . . . . . . . . . . . . . . . . . . . 42 in depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 selecting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 linker object executable image specifying filename of (-o) . . . . . . . . . . . . . . . . . . . . . . 203 linker options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 reading from file (-f) . . . . . . . . . . . . . . . . . . . . . . . . . . 197 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
typographic convention . . . . . . . . . . . . . . . . . . . . . . xxxiii linking from the command line . . . . . . . . . . . . . . . . . . . . . . . . . 19 process for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 process for, an overview . . . . . . . . . . . . . . . . . . . . . . . . . 12 Lippman, Stanley B. . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii list (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 listing, generating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 literals, compound. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 literature, recommended . . . . . . . . . . . . . . . . . . . . . . . . . xxxii little-endian (byte order) . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 __LITTLE_ENDIAN__ (predefined symbol) . . . . . . . . . . 285 __little_endian (extended keyword) . . . . . . . . . . . . . . . . . 238 llabs, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 lldiv, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 local variables, See auto variables locale support DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 adding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 changing at runtime. . . . . . . . . . . . . . . . . . . . . . . . . . 83 removing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 locale.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 located data, declaring extern . . . . . . . . . . . . . . . . . . . . . . 132 location counter, definition of . . . . . . . . . . . . . . . . . . . . . . 371 location (pragma directive) . . . . . . . . . . . . . . . . . . . . 132, 251 --log (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 logical address, definition of . . . . . . . . . . . . . . . . . . . . . . . 375 --log_file (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . 199 long double (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 long float (data type), synonym for double . . . . . . . . . . . . 229 loop overhead, reducing . . . . . . . . . . . . . . . . . . . . . . . . . . 180 loop unrolling (compiler transformation) . . . . . . . . . . . . . 137 disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 loop-invariant expressions. . . . . . . . . . . . . . . . . . . . . . . . . 137 low-level processor operations . . . . . . . . . . . . . . . . . 221, 259 accessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 __low_level_init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 low_level_init.c. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
389
low_level_init.s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 __lseek (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 lzw, packing algorithm for initializers . . . . . . . . . . . . . . . . 306 L-value, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
M
-map (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 macros definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 embedded in #pragma optimize . . . . . . . . . . . . . . . . . . 253 ERANGE (in errno.h) . . . . . . . . . . . . . . . . . . . . . . . . . 356 inclusion of assert . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287 NULL, implementation-defined behavior . . . . . . . . . . 356 substituted in #pragma directives . . . . . . . . . . . . . . . . . 221 variadic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 MAC, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 mailbox (RTOS), definition of . . . . . . . . . . . . . . . . . . . . . 368 main (function), definition . . . . . . . . . . . . . . . . . . . . . . . . 350 malloc (library function) See also heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 implementation-defined behavior. . . . . . . . . . . . . . . . . 358 --mangled_names_in_messages (linker option) . . . . . . . . 199 mangling, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Mann, Bernhard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii map file, producing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 map (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 math.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 math.h, added C functionality . . . . . . . . . . . . . . . . . . . . . . 295 MATH_ERREXCEPT, C99 extension . . . . . . . . . . . . . . . 295 math_errhandling, C99 extension . . . . . . . . . . . . . . . . . . . 295 MATH_ERRNO, C99 extension . . . . . . . . . . . . . . . . . . . . 295 __MCR (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 267 member functions, pointers to . . . . . . . . . . . . . . . . . . . . . . 111 MemManage_Handler (exception function) . . . . . . . . . . . . 36 memory allocating in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 dynamic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 non-initialized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 RAM, saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 releasing in C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 used by global or static variables . . . . . . . . . . . . . . . . . . 25 memory access cost, definition of . . . . . . . . . . . . . . . . . . . 368 memory area, definition of . . . . . . . . . . . . . . . . . . . . . . . . 368 memory bank, definition of . . . . . . . . . . . . . . . . . . . . . . . . 369 memory layout, ARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 memory management, type-safe . . . . . . . . . . . . . . . . . . . . 107 memory map definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 output from linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 memory model, definition of. . . . . . . . . . . . . . . . . . . . . . . 369 memory (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 356 memory (STL header file). . . . . . . . . . . . . . . . . . . . . . . . . 293 message (pragma directive). . . . . . . . . . . . . . . . . . . . . . . . 252 messages disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187, 206 forcing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 --mfc (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . 175 microcontroller, definition of . . . . . . . . . . . . . . . . . . . . . . 369 microprocessor, definition of . . . . . . . . . . . . . . . . . . . . . . 369 --migration_preprocessor_extensions (compiler option) . . 175 --misrac_verbose (compiler option) . . . . . . . . . . . . . . . . . 159 --misrac_verbose (linker option) . . . . . . . . . . . . . . . . . . . . 190 --misrac1998 (compiler option) . . . . . . . . . . . . . . . . . . . . 159 --misrac1998 (linker option) . . . . . . . . . . . . . . . . . . . . . . . 190 --misrac2004 (compiler option) . . . . . . . . . . . . . . . . . . . . 159 --misrac2004 (linker option) . . . . . . . . . . . . . . . . . . . . . . . 190 module consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 rtmodel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 modules definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 module_name (pragma directive) . . . . . . . . . . . . . . . . . . . 356 Motorola S-records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
390
Index
__MRC (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 268 multibyte character support . . . . . . . . . . . . . . . . . . . . . . . . 170 multiple inheritance in Extended EC++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 missing from Embedded C++ . . . . . . . . . . . . . . . . . . . 107 missing from STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Multiply and accumulate, definition of . . . . . . . . . . . . . . . 368 multitasking, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 370 multi-file compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 mutable attribute, in Extended EC++ . . . . . . . . . . . . 108, 111
N
names block (call frame information) . . . . . . . . . . . . . . . . 103 namespace support in Extended EC++ . . . . . . . . . . . . . . . . . . . . . . . . 108, 111 missing from Embedded C++ . . . . . . . . . . . . . . . . . . . 108 naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiv NAN, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 NDEBUG (preprocessor symbol) . . . . . . . . . . . . . . . . . . . 287 __nested (extended keyword) . . . . . . . . . . . . . . . . . . . . . . 239 nested interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 new (keyword) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 new (library header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 292 new.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . . 292 NMI_Handler (exception function) . . . . . . . . . . . . . . . . . . . 36 non-banked memory, definition of . . . . . . . . . . . . . . . . . . 369 non-initialized memory, definition of . . . . . . . . . . . . . . . . 369 non-initialized variables, hints for . . . . . . . . . . . . . . . . . . . 143 non-scalar parameters, avoiding . . . . . . . . . . . . . . . . . . . . 140 non-volatile storage, definition of . . . . . . . . . . . . . . . . . . . 369 NOP (assembler instruction) . . . . . . . . . . . . . . . . . . . . . . . 268 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 __noreturn (extended keyword) . . . . . . . . . . . . . . . . . . . . 239 Normal DLIB (library configuration) . . . . . . . . . . . . . . . . . 63 Not a number (NaN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 no-init sections, definition of . . . . . . . . . . . . . . . . . . . . . . 369
--no_clustering (compiler option) . . . . . . . . . . . . . . . . . . . 176 --no_code_motion (compiler option) . . . . . . . . . . . . . . . . 176 --no_const_align (compiler option) . . . . . . . . . . . . . . . . . . 176 --no_cse (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . 177 --no_guard_calls (compiler option) . . . . . . . . . . . . . . . . . . 177 __no_init (extended keyword) . . . . . . . . . . . . . . . . . 143, 239 --no_inline (compiler option) . . . . . . . . . . . . . . . . . . . . . . 178 --no_library_search (linker option) . . . . . . . . . . . . . . . . . . 201 --no_locals (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 201 __no_operation (intrinsic function) . . . . . . . . . . . . . . . . . . 268 --no_path_in_file_macros (compiler option) . . . . . . . . . . . 178 no_pch (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 356 --no_remove (linker option) . . . . . . . . . . . . . . . . . . . . . . . 201 --no_scheduling (compiler option) . . . . . . . . . . . . . . . . . . 178 --no_typedefs_in_diagnostics (compiler option) . . . . . . . . 179 --no_unaligned_access (compiler option) . . . . . . . . . . . . . 180 --no_unroll (compiler option) . . . . . . . . . . . . . . . . . . . . . . 180 --no_veneer (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 202 --no_warnings (compiler option) . . . . . . . . . . . . . . . . . . . 181 --no_warnings (linker option) . . . . . . . . . . . . . . . . . . . . . . 202 --no_wrap_diagnostics (compiler option) . . . . . . . . . . . . . 181 --no_wrap_diagnostics (linker option) . . . . . . . . . . . . . . . 202 NULL (macro), implementation-defined behavior . . . . . . 356 numbers (in linker configuration file) . . . . . . . . . . . . . . . . 316 numeric (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . 293
O
-O (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 -o (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 -o (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 -o (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 -o (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 objcopy, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 objdump, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 object attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 object file (absolute), definition of . . . . . . . . . . . . . . . . . . 369 object file (relocatable), definition of . . . . . . . . . . . . . . . . 370
391
object filename specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 specifying in compiler . . . . . . . . . . . . . . . . . . . . . . . . . 182 specifying in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 object module, ose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 object, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 369370 object_attribute (pragma directive) . . . . . . . . . . . . . . 143, 252 once (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . . . 356 --only_stdout (compiler option) . . . . . . . . . . . . . . . . . . . . 182 --only_stdout (linker option) . . . . . . . . . . . . . . . . . . . . . . . 203 __open (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 operator precedence, definition of . . . . . . . . . . . . . . . . . . . 370 operators See also @ (operator) definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 optimization clustering, disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 code motion, disabling . . . . . . . . . . . . . . . . . . . . . . . . . 176 common sub-expression elimination, disabling . . . . . . 177 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 function inlining, disabling (--no_inline) . . . . . . . . . . . 178 hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 loop unrolling, disabling . . . . . . . . . . . . . . . . . . . . . . . 180 scheduling, disabling . . . . . . . . . . . . . . . . . . . . . . . . . . 178 specifying (-O) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 type-based alias analysis, disabling (--tbaa) . . . . . . . . . 179 using inline assembler code . . . . . . . . . . . . . . . . . . . . . . 94 using pragma directive . . . . . . . . . . . . . . . . . . . . . . . . . 252 optimization levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 optimize (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . 252 option parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 options, compiler. See compiler options options, iarchive. See iarchive options options, ielfdump. See ielfdump options options, ielftool. See ielftool options options, iobjmanip. See iobjmanip options options, isymexport. See isymexport options
options, linker. See linker options Oram, Andy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii --ose_load_module (linker option) . . . . . . . . . . . . . . . . . . 203 ostream (library header file) . . . . . . . . . . . . . . . . . . . . . . . 292 output from preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 specifying for linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 --output (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . 183 --output (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 overhead, reducing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 overlay, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
P
pack (pragma directive) . . . . . . . . . . . . . . . . . . . . . . 217, 253 packbits, packing algorithm for initializers . . . . . . . . . . . . 306 __packed (extended keyword). . . . . . . . . . . . . . . . . . . . . . 240 packed structure types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 packing, algorithms for initializers . . . . . . . . . . . . . . . . . . 306 parameters function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 hidden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 non-scalar, avoiding . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99100 rules for specifying a file or directory . . . . . . . . . . . . . 156 specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99, 101 typographic convention . . . . . . . . . . . . . . . . . . . . . . xxxiii part number, of this guide . . . . . . . . . . . . . . . . . . . . . . . . . . . ii PendSV_Handler (exception function) . . . . . . . . . . . . . . . . 36 peripheral units, definition of . . . . . . . . . . . . . . . . . . . . . . 370 permanent registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 perror (library function), implementation-defined behavior . . . . . . . . . . . . . . . . . . . 358 pipeline, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 --pi_veneer (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 204 place at (linker directive) . . . . . . . . . . . . . . . . . . . . . . . . . 309 place in (linker directive) . . . . . . . . . . . . . . . . . . . . . . . . . 310
392
Index
placement code and data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 in named sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 of code and data, introduction to . . . . . . . . . . . . . . . . . . 42 --place_holder (linker option) . . . . . . . . . . . . . . . . . . . . . . 204 pointer types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 mixing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 pointers casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 implementation-defined behavior. . . . . . . . . . . . . . . . . 353 polymorphism, in Embedded C++ . . . . . . . . . . . . . . . . . . 107 porting, code containing pragma directives . . . . . . . . . . . . 246 _Pragma (predefined symbol) . . . . . . . . . . . . . . . . . . . . . . 287 #pragma directive, definition of . . . . . . . . . . . . . . . . . . . . 370 pragma directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 for absolute located data . . . . . . . . . . . . . . . . . . . . . . . 132 list of all recognized . . . . . . . . . . . . . . . . . . . . . . . . . . . 355 pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217, 253 precedence, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 370 predefined symbols overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 --predef_macro (compiler option) . . . . . . . . . . . . . . . . . . . 183 preemptive multitasking, definition of . . . . . . . . . . . . . . . 370 Prefetch_Handler (exception function) . . . . . . . . . . . . . . . . 32 --preinclude (compiler option) . . . . . . . . . . . . . . . . . . . . . 183 --preprocess (compiler option) . . . . . . . . . . . . . . . . . . . . . 184 preprocessor definition of. See C-style preprocessor output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 overview of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 preprocessor directives comments at the end of . . . . . . . . . . . . . . . . . . . . . . . . 230 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
implementation-defined behavior. . . . . . . . . . . . . . . . . 354 #pragma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 preprocessor extensions compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 #warning message . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 __VA_ARGS__ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 preprocessor symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 defining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164, 193 preserved registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 __PRETTY_FUNCTION__ (predefined symbol). . . . . . . 285 primitives, for special functions . . . . . . . . . . . . . . . . . . . . . 30 print formatter, selecting . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 printf (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 choosing formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 configuration symbols . . . . . . . . . . . . . . . . . . . . . . . . . . 79 implementation-defined behavior. . . . . . . . . . . . . . . . . 358 __printf_args (pragma directive) . . . . . . . . . . . . . . . . . . . . 254 processor configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 processor operations accessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 low-level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221, 259 processor variant, definition of . . . . . . . . . . . . . . . . . . . . . 370 program counter, definition of. . . . . . . . . . . . . . . . . . . . . . 370 program entry label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 program location counter, definition of . . . . . . . . . . . . . . . 371 programming hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 __program_start (label) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 project options, definition of . . . . . . . . . . . . . . . . . . . . . . . 371 projects basic settings for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 setting up for a library . . . . . . . . . . . . . . . . . . . . . . . . . . 71 PROM, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 prototypes, enforcing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 ptrdiff_t (integer type). . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 PUBLIC (assembler directive) . . . . . . . . . . . . . . . . . . . . . 184 publication date, of this guide . . . . . . . . . . . . . . . . . . . . . . . . ii --public_equ (compiler option) . . . . . . . . . . . . . . . . . . . . . 184 public_equ (pragma directive) . . . . . . . . . . . . . . . . . . . . . 356
393
Q
__QADD (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 268 __QADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 268 __QADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 269 __QASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 269 QCCARM (environment variable) . . . . . . . . . . . . . . . . . . 148 __QDADD (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 269 __QDOUBLE (intrinsic function) . . . . . . . . . . . . . . . . . . . 269 __QDSUB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 270 __QFlag (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 270 __QSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 271 __QSUB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 270 __QSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 270 __QSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 270 qualifiers definition of. See type qualifiers const and volatile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 implementation-defined behavior. . . . . . . . . . . . . . . . . 354 queue (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 293
R
-r (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 -r (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 raise (library function), configuring support for . . . . . . . . . 84 raise.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 RAM example of declaring region . . . . . . . . . . . . . . . . . . . . . . 43 execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 initializers copied from ROM . . . . . . . . . . . . . . . . . . . . 18 running code from . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 saving memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 __ramfunc (extended keyword). . . . . . . . . . . . . . . . . . 30, 240 range errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 range, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 --raw (ielfdump option). . . . . . . . . . . . . . . . . . . . . . . . . . . 338
__read (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 read formatter, selecting . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 reading guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxix reading, recommended . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii read-only sections, definition of . . . . . . . . . . . . . . . . . . . . 371 realloc (library function) implementation-defined behavior. . . . . . . . . . . . . . . . . 358 See also heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 real-time operating system, definition of. . . . . . . . . . . . . . 371 real-time system, definition of . . . . . . . . . . . . . . . . . . . . . 371 recursive functions avoiding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 storing data on stack . . . . . . . . . . . . . . . . . . . . . . . . 2627 --redirect (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . 205 reentrancy (DLIB). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290 reference information, typographic convention . . . . . . . xxxiii region . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 region expression definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 in linker configuration file . . . . . . . . . . . . . . . . . . . . . . 301 region literal definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 in linker configuration file . . . . . . . . . . . . . . . . . . . . . . 299 region, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 register constant, definition of . . . . . . . . . . . . . . . . . . . . . . 371 register locking, definition of . . . . . . . . . . . . . . . . . . . . . . 371 register parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 99100 register variables, definition of . . . . . . . . . . . . . . . . . . . . . 371 registered trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii registers assigning to parameters . . . . . . . . . . . . . . . . . . . . . . . . 100 callee-save, stored on stack . . . . . . . . . . . . . . . . . . . . . . 26 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 implementation-defined behavior. . . . . . . . . . . . . . . . . 353 in assembler-level routines . . . . . . . . . . . . . . . . . . . . . . . 97 preserved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 reinterpret_cast (cast operator) . . . . . . . . . . . . . . . . . . . . . 108
394
Index
.rel (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .rela (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 relay, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 relocatable segments, definition of . . . . . . . . . . . . . . . . . . 372 relocation errors, resolving . . . . . . . . . . . . . . . . . . . . . . . . . 58 remark (diagnostic message) . . . . . . . . . . . . . . . . . . . . . . . 153 classifying for compiler . . . . . . . . . . . . . . . . . . . . . . . . 166 classifying for linker . . . . . . . . . . . . . . . . . . . . . . . . . . 194 enabling in compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 185 enabling in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 --remarks (compiler option) . . . . . . . . . . . . . . . . . . . . . . . 185 --remarks (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . 205 remove (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 implementation-defined behavior. . . . . . . . . . . . . . . . . 357 --remove_section (iobjmanip option) . . . . . . . . . . . . . . . . 340 rename (isymexport directive). . . . . . . . . . . . . . . . . . . . . . 346 rename (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 implementation-defined behavior. . . . . . . . . . . . . . . . . 357 --rename_section (iobjmanip option) . . . . . . . . . . . . . . . . 340 --rename_symbol (iobjmanip option) . . . . . . . . . . . . . . . . 341 --replace (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . 327 __ReportAssert (library function) . . . . . . . . . . . . . . . . . . . . 85 required (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 254 --require_prototypes (compiler option) . . . . . . . . . . . . . . . 185 reset, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 return values, from functions . . . . . . . . . . . . . . . . . . . . . . 101 __REV (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 271 __REVSH (intrinsic function). . . . . . . . . . . . . . . . . . . . . . 271 Ritchie, Dennis M. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii ROM to RAM, copying . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 ROM-monitor, definition of . . . . . . . . . . . . . . . . . . . . . . . 372 __root (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 241 Round Robin, definition of . . . . . . . . . . . . . . . . . . . . . . . . 372 routines, time-critical . . . . . . . . . . . . . . . . . . . . . 91, 221, 259 rtmodel (assembler directive) . . . . . . . . . . . . . . . . . . . . . . . 89 rtmodel (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 255 RTOS, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 rtti support, missing from STL . . . . . . . . . . . . . . . . . . . . . 108
runtime environment DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 setting options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 runtime libraries choosing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 choosing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 customizing without rebuilding . . . . . . . . . . . . . . . . . 66 naming convention . . . . . . . . . . . . . . . . . . . . . . . . . . 65 overriding modules in . . . . . . . . . . . . . . . . . . . . . . . . 69 runtime model attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 runtime model definitions . . . . . . . . . . . . . . . . . . . . . . . . . 255 runtime type information, missing from Embedded C++ . 108 R-value, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
S
-S (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 -s (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 __SADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 271 __SADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 271 __SASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 272 saturation arithmetics, definition of. . . . . . . . . . . . . . . . . . 372 scanf (library function) choosing formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 configuration symbols . . . . . . . . . . . . . . . . . . . . . . . . . . 79 implementation-defined behavior. . . . . . . . . . . . . . . . . 358 __scanf_args (pragma directive) . . . . . . . . . . . . . . . . . . . . 256 scheduler (RTOS), definition of . . . . . . . . . . . . . . . . . . . . 372 scheduling (compiler transformation) . . . . . . . . . . . . . . . . 139 disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 scope, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 scratch registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 section allocation of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
395
--section (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . 338 section fragment, definition of . . . . . . . . . . . . . . . . . . . . . 372 section names declaring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 section selection, definition of . . . . . . . . . . . . . . . . . . . . . 373 section (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . . 256 sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 section-selectors (in linker configuration file) . . . . . . . . . . 311 __section_begin (extended operator) . . . . . . . . . . . . . . . . 223 __section_end (extended operator) . . . . . . . . . . . . . . . . . . 223 __section_size (extended operator) . . . . . . . . . . . . . . . . . . 223 segment (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . 256 __SEL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 272 semaphores, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 373 --semihosting (linker option). . . . . . . . . . . . . . . . . . . . . . . 205 --separate_cluster_for_initialized_variables (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 set (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 setjmp.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 setlocale (library function) . . . . . . . . . . . . . . . . . . . . . . . . . 83 settings, basic for project configuration . . . . . . . . . . . . . . . 19 __set_BASEPRI (intrinsic function) . . . . . . . . . . . . . . . . . 272 __set_CONTROL (intrinsic function) . . . . . . . . . . . . . . . . 272 __set_CPSR (intrinsic function) . . . . . . . . . . . . . . . . . . . . 273 __set_FAULTMASK (intrinsic function) . . . . . . . . . . . . . 273 __set_interrupt_state (intrinsic function) . . . . . . . . . . . . . 273 __set_PRIMASK (intrinsic function) . . . . . . . . . . . . . . . . 273 severity level definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 of diagnostic messages . . . . . . . . . . . . . . . . . . . . . . . . . 153 of diagnostic messages, specifying . . . . . . . . . . . . . . . 153 SFR accessing special function registers . . . . . . . . . . . . . . . 142 declaring extern special function registers . . . . . . . . . . 132 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 __SHADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 273 __SHADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 274
shared object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150, 200 sharing, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 373, 375 __SHASX (intrinsic function). . . . . . . . . . . . . . . . . . . . . . 274 short addressing, definition of . . . . . . . . . . . . . . . . . . . . . . 373 short (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 show (isymexport directive) . . . . . . . . . . . . . . . . . . . . . . . 345 __SHSAX (intrinsic function). . . . . . . . . . . . . . . . . . . . . . 274 .shstrtab (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 __SHSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 274 __SHSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 274 side-effect, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . 373 signal (library function) configuring support for . . . . . . . . . . . . . . . . . . . . . . . . . 84 implementation-defined behavior. . . . . . . . . . . . . . . . . 357 signals, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 signal.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 signal.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 signbit, C99 extension. . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 signed char (data type) . . . . . . . . . . . . . . . . . . . . . . . 210211 specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 signed int (data type). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 signed long long (data type) . . . . . . . . . . . . . . . . . . . . . . . 211 signed long (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 signed short (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 --silent (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 187 --silent (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . 327 --silent (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 --silent (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 silent operation specifying in compiler . . . . . . . . . . . . . . . . . . . . . . . . . 187 specifying in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 --simple (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . 334 simulator, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 64-bits (floating-point format) . . . . . . . . . . . . . . . . . . . . . 214 sizeof, using in preprocessor extensions . . . . . . . . . . . . . . 175 size_t (integer type) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 skeleton code creating for assembler language interface . . . . . . . . . . . 94 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
396
Index
skeleton.s (assembler source output) . . . . . . . . . . . . . . . . . . 95 slist (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 smallest, packing algorithm for initializers . . . . . . . . . . . . 306 __SMUL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 275 snprintf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 software interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 source files, list all referred . . . . . . . . . . . . . . . . . . . . . . . . 172 special function registers (SFR) . . . . . . . . . . . . . . . . . . . . 142 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 special function types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 sprintf (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 choosing formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 --srec (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 --srec-len (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . 335 --srec-s3only (ielftool option) . . . . . . . . . . . . . . . . . . . . . . 335 __SSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 275 sscanf (library function) choosing formatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 sstream (library header file) . . . . . . . . . . . . . . . . . . . . . . . 292 __SSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 275 __SSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 275 stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 advantages and problems using . . . . . . . . . . . . . . . . . . . 26 aligning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 cleaning after function return . . . . . . . . . . . . . . . . . . . . 102 contents of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 internal data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 saving space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 stack frames, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 373 stack parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99, 101 stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 stack (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 standard error redirecting in compiler . . . . . . . . . . . . . . . . . . . . . . . . . 182 redirecting in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
standard input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 standard libraries, definition of . . . . . . . . . . . . . . . . . . . . . 374 standard output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 specifying in compiler . . . . . . . . . . . . . . . . . . . . . . . . . 182 specifying in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 standard template library (STL) in Extended EC++ . . . . . . . . . . . . . . . . . . . . 108, 111, 293 missing from Embedded C++ . . . . . . . . . . . . . . . . . . . 108 startup system. See system startup statements, implementation-defined behavior . . . . . . . . . . 354 static clustering (compiler transformation) . . . . . . . . . . . . 138 static objects, definition of . . . . . . . . . . . . . . . . . . . . . . . . 374 static overlay, definition of . . . . . . . . . . . . . . . . . . . . . . . . 374 static variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 taking the address of . . . . . . . . . . . . . . . . . . . . . . . . . . 139 statically allocated memory, definition of . . . . . . . . . . . . . 374 static_cast (cast operator) . . . . . . . . . . . . . . . . . . . . . . . . . 108 __STC (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 276 __STCL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 276 __STCL_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . 276 __STC_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . . 276 __STC2 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 276 __STC2L (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 276 __STC2L_noidx (intrinsic function) . . . . . . . . . . . . . . . . . 276 __STC2_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . 276 std namespace, missing from EC++ and Extended EC++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 stdarg.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 stdbool.h (library header file) . . . . . . . . . . . . . . . . . . 211, 291 added C functionality . . . . . . . . . . . . . . . . . . . . . . . . . . 295 __STDC__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 285 STDC (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . . 356 __STDC_VERSION__ (predefined symbol) . . . . . . . . . . 285 stddef.h (library header file) . . . . . . . . . . . . . . . . . . . 212, 291 stderr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 182, 203 stdexcept (library header file) . . . . . . . . . . . . . . . . . . . . . . 292 stdin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 implementation-defined behavior. . . . . . . . . . . . . . . . . 357 stdint.h (library header file). . . . . . . . . . . . . . . . . . . . 291, 294 stdint.h, added C functionality . . . . . . . . . . . . . . . . . . . . . 295
397
stdio.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 stdio.h, additional C functionality . . . . . . . . . . . . . . . . . . . 295 stdlib.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 stdlib.h, additional C functionality . . . . . . . . . . . . . . . . . . 296 stdout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 182, 203 implementation-defined behavior. . . . . . . . . . . . . . . . . 357 Steele, Guy L. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii steering file, input to isymexport. . . . . . . . . . . . . . . . . . . . 345 stepping, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 streambuf (library header file). . . . . . . . . . . . . . . . . . . . . . 292 streams, supported in Embedded C++. . . . . . . . . . . . . . . . 108 strerror (library function) implementation-defined behavior . . . . . . . . . . . . . . . . . . . 359 __STREX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 277 --strict_ansi (compiler option). . . . . . . . . . . . . . . . . . . . . . 187 string (library header file) . . . . . . . . . . . . . . . . . . . . . . . . . 292 strings, supported in Embedded C++ . . . . . . . . . . . . . . . . 108 string.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . 291 --strip (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 --strip (iobjmanip option) . . . . . . . . . . . . . . . . . . . . . . . . . 341 --strip (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Stroustrup, Bjarne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxii strstream (library header file) . . . . . . . . . . . . . . . . . . . . . . 292 .strtab (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 strtod (library function), configuring support for . . . . . . . . 85 strtod, in stdlib.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 strtof, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 strtold, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 strtoll, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 strtoull, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 structure types alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216217 layout of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 packed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 structure value, definition of . . . . . . . . . . . . . . . . . . . . . . . 374 structures aligning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 anonymous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129, 223 implementation-defined behavior. . . . . . . . . . . . . . . . . 353
incomplete arrays as last element . . . . . . . . . . . . . . . . . 226 packing and unpacking . . . . . . . . . . . . . . . . . . . . . . . . 129 subnormal numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 213214 support, technical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 SVC #immed, for software interrupts . . . . . . . . . . . . . . . . . 34 SVC_Handler (exception function) . . . . . . . . . . . . . . . . . . . 36 __swi (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 241 SWI_Handler (exception function) . . . . . . . . . . . . . . . . . . . 32 swi_number (pragma directive) . . . . . . . . . . . . . . . . . . . . 257 __SWP (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 277 __SWPB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 277 symbol names, using in preprocessor extensions . . . . . . . 175 symbolic location, definition of . . . . . . . . . . . . . . . . . . . . 374 symbols anonymous, creating . . . . . . . . . . . . . . . . . . . . . . . . . . 226 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 directing from one to another . . . . . . . . . . . . . . . . . . . . 205 including in output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 overview of predefined. . . . . . . . . . . . . . . . . . . . . . . . . . . 7 preprocessor, defining . . . . . . . . . . . . . . . . . . . . . 164, 193 --symbols (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . 328 .symtab (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 syntax command line options . . . . . . . . . . . . . . . . . . . . . . . . . 155 extended keywords. . . . . . . . . . . . . . . . . . . . . . . . 234235 invoking compiler and linker . . . . . . . . . . . . . . . . . . . . 147 system startup customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 initialization phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 system termination C-SPY interface to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 DLIB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 system (library function) configuring support for . . . . . . . . . . . . . . . . . . . . . . . . . 83 implementation-defined behavior. . . . . . . . . . . . . . . . . 359 system_include (pragma directive) . . . . . . . . . . . . . . . . . . 356 SysTick_Handler (exception function) . . . . . . . . . . . . . . . . 36
398
Index
T
-t (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 target, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 __task (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 242 task, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 technical support, IAR Systems . . . . . . . . . . . . . . . . . . . . 154 template support in Extended EC++ . . . . . . . . . . . . . . . . . . . . . . . . 108, 110 missing from Embedded C++ . . . . . . . . . . . . . . . . . . . 107 tentative definition, definition of . . . . . . . . . . . . . . . . . . . . 374 Terminal I/O window making available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 terminal I/O, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 374 terminal output, speeding up . . . . . . . . . . . . . . . . . . . . . . . . 87 termination of system. See system termination terminology. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii, 361 32-bits (floating-point format) . . . . . . . . . . . . . . . . . . . . . 213 this (pointer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 thread, definition of. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 --thumb (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . 187 __thumb (extended keyword) . . . . . . . . . . . . . . . . . . . . . . 243 Thumb, CPU mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 __TID__ (predefined symbol). . . . . . . . . . . . . . . . . . . . . . 286 __TIME__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 285 time zone (library function) implementation-defined behavior . . . . . . . . . . . . . . . . . . . 359 time (library function), configuring support for . . . . . . . . . 85 timer, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 timeslice, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 time-critical routines . . . . . . . . . . . . . . . . . . . . . . 91, 221, 259 time.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 time.h (library header file) . . . . . . . . . . . . . . . . . . . . . . . . 291 tips, programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 --toc (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 tools icon, in this guide . . . . . . . . . . . . . . . . . . . . . . . . . xxxiii trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii transformations, compiler . . . . . . . . . . . . . . . . . . . . . . . . . 134 translation unit, definition of . . . . . . . . . . . . . . . . . . . . . . . 374
translation, implementation-defined behavior . . . . . . . . . . 349 trap, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 type attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 specifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 type qualifiers const and volatile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 implementation-defined behavior. . . . . . . . . . . . . . . . . 354 typedefs excluding from diagnostics . . . . . . . . . . . . . . . . . . . . . 179 repeated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 using in preprocessor extensions . . . . . . . . . . . . . . . . . 175 type-based alias analysis (compiler transformation) . . . . . 138 disabling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 type-safe memory management . . . . . . . . . . . . . . . . . . . . 107 type_attribute (pragma directive) . . . . . . . . . . . . . . . . . . . 257 typographic conventions . . . . . . . . . . . . . . . . . . . . . . . . xxxiii
U
__UADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 277 __UADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 277 __UASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 278 UBROF definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 __UHADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 278 __UHADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 278 __UHASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 278 __UHSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 278 __UHSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 279 __UHSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 279 uintptr_t (integer type) . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 Undefined_Handler (exception function) . . . . . . . . . . . . . . 32 underflow range errors, implementation-defined behavior . . . . . . . . . . . . . . . . . . . 356 unions anonymous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129, 223 implementation-defined behavior. . . . . . . . . . . . . . . . . 353
399
unsigned char (data type) . . . . . . . . . . . . . . . . . . . . . 210211 changing to signed char . . . . . . . . . . . . . . . . . . . . . . . . 162 unsigned int (data type) . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 unsigned long long (data type) . . . . . . . . . . . . . . . . . . . . . 211 unsigned long (data type) . . . . . . . . . . . . . . . . . . . . . . . . . 211 unsigned short (data type) . . . . . . . . . . . . . . . . . . . . . . . . . 210 __UQADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 279 __UQADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 279 __UQASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 280 __UQSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 280 __UQSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 280 __UQSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 280 UsageFault_Handler (exception function). . . . . . . . . . . . . . 36 __USAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 280 --use_unix_directory_separators (compiler option). . . . . . 188 __USUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 281 __USUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 281 utility (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 293
V
-V (iarchive option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 value expressions, definition of . . . . . . . . . . . . . . . . . . . . . 375 variables auto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 defined inside a function . . . . . . . . . . . . . . . . . . . . . . . . 26 global placement in memory . . . . . . . . . . . . . . . . . . . . . . . . 25 hints for choosing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 local. See auto variables non-initialized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 placing at absolute addresses . . . . . . . . . . . . . . . . . . . . 133 placing in named sections . . . . . . . . . . . . . . . . . . . . . . 133 static placement in memory . . . . . . . . . . . . . . . . . . . . . . . . 25 taking the address of . . . . . . . . . . . . . . . . . . . . . . . . 139 vector floating-point unit . . . . . . . . . . . . . . . . . . . . . . . . . 172 vector (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . . 356 vector (STL header file) . . . . . . . . . . . . . . . . . . . . . . . . . . 293
__vector_table, array holding vector table . . . . . . . . . . . . . 36 veneers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 __VER__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 286 --verbose (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . 328 --verbose (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . 335 version IAR Embedded Workbench . . . . . . . . . . . . . . . . . . . . . . . ii of compiler. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 VFP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 vfscanf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 vfwscanf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 296 virtual address, definition of . . . . . . . . . . . . . . . . . . . . . . . 375 virtual space, definition of . . . . . . . . . . . . . . . . . . . . . . . . 375 void, pointers to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 volatile storage, definition of . . . . . . . . . . . . . . . . . . . . . . 375 volatile (keyword) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 volatile, declaring objects . . . . . . . . . . . . . . . . . . . . . . . . . 218 von Neumann architecture, definition of . . . . . . . . . . . . . . 375 vscanf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 vsnprintf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 295 vsscanf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 vswscanf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 296 vwscanf, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . 296
W
#warning message (preprocessor extension) . . . . . . . . . . . 288 warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 classifying in compiler . . . . . . . . . . . . . . . . . . . . . . . . . 167 classifying in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 disabling in compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 181 disabling in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 exit code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 in linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 warnings icon, in this guide . . . . . . . . . . . . . . . . . . . . . xxxiv warnings (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . 356 --warnings_affect_exit_code (compiler option) . . . . 151, 188 --warnings_affect_exit_code (linker option) . . . . . . . . . . . 206 --warnings_are_errors (compiler option) . . . . . . . . . . . . . 188
400
Index
--warnings_are_errors (linker option) . . . . . . . . . . . . . . . . 206 watchpoints, definition of . . . . . . . . . . . . . . . . . . . . . . . . . 375 wchar.h (library header file) . . . . . . . . . . . . . . . . . . . 291, 294 wchar.h, added C functionality . . . . . . . . . . . . . . . . . . . . . 296 wchar_t (data type), adding support for in C . . . . . . . . . . . 211 wcstof, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 wcstolb, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 wctype.h (library header file) . . . . . . . . . . . . . . . . . . . . . . 291 wctype.h, added C functionality . . . . . . . . . . . . . . . . . . . . 296 __weak (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . 243 weak (pragma directive) . . . . . . . . . . . . . . . . . . . . . . . . . . 258 web sites, recommended . . . . . . . . . . . . . . . . . . . . . . . . . xxxii __write (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
X
-x (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 XLINK, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 xreportassert.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Z
zeros, packing algorithm for initializers . . . . . . . . . . . . . . 306 zero-initialized sections, definition of . . . . . . . . . . . . . . . . 375 zero-overhead loop, definition of . . . . . . . . . . . . . . . . . . . 375 zone, definition of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Symbols
#include files, specifying . . . . . . . . . . . . . . . . . . . . . 149, 173 #pragma directive, definition of . . . . . . . . . . . . . . . . . . . . 370 #warning message (preprocessor extension) . . . . . . . . . . . 288 -D (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 -d (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 -e (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 -f (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 -f (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 -f (iobjmanip option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
-f (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 -I (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 -l (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 for creating skeleton code . . . . . . . . . . . . . . . . . . . . . . . 95 -O (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 -o (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 -o (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 -o (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 -o (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 -r (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 -r (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 -S (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 -s (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 -t (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 -V (iarchive option). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 -x (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 --aapcs (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 161 --aeabi (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 161 --align_sp_on_irq (compiler option) . . . . . . . . . . . . . . . . . 161 --all (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 --arm (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . 162 --BE32 (linker option). . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 --BE8 (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 --bin (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 --char_is_signed (compiler option) . . . . . . . . . . . . . . . . . . 162 --checksum (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . 332 --config (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 --config_def (linker option). . . . . . . . . . . . . . . . . . . . . . . . 192 --cpp_init_routine (linker option) . . . . . . . . . . . . . . . . . . . 193 --cpu (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 --cpu (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 --cpu_mode (compiler option) . . . . . . . . . . . . . . . . . . . . . 163 --create (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . 325 --debug (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 164 --define_symbol (linker option) . . . . . . . . . . . . . . . . . . . . 193 --delete (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . 326 --dependencies (compiler option) . . . . . . . . . . . . . . . . . . . 165 --diagnostics_tables (compiler option) . . . . . . . . . . . . . . . 167 --diagnostics_tables (linker option) . . . . . . . . . . . . . . . . . . 196
401
--diag_error (compiler option) . . . . . . . . . . . . . . . . . . . . . 166 --diag_error (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 194 --diag_remark (compiler option) . . . . . . . . . . . . . . . . . . . . 166 --diag_remark (linker option) . . . . . . . . . . . . . . . . . . . . . . 194 --diag_suppress (compiler option) . . . . . . . . . . . . . . . . . . 167 --diag_suppress (linker option) . . . . . . . . . . . . . . . . . . . . . 195 --diag_warning (compiler option) . . . . . . . . . . . . . . . . . . . 167 --diag_warning (linker option) . . . . . . . . . . . . . . . . . . . . . 195 --discard_unused_publics (compiler option) . . . . . . . . . . . 168 --dlib_config (compiler option). . . . . . . . . . . . . . . . . . . . . 168 --ec++ (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . 169 --edit (isymexport option) . . . . . . . . . . . . . . . . . . . . . . . . . 344 --eec++ (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 169 --enable_hardware_workaround (compiler option) . . . . . . 170 --enable_multibytes (compiler option) . . . . . . . . . . . . . . . 170 --endian (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . 170 --entry (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 --enum_is_int (compiler option) . . . . . . . . . . . . . . . . . . . . 171 --error_limit (compiler option) . . . . . . . . . . . . . . . . . . . . . 171 --error_limit (linker option) . . . . . . . . . . . . . . . . . . . . . . . 196 --export_builtin_config (linker option) . . . . . . . . . . . . . . . 197 --extract (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . 326 --fill (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 --force_output (linker option) . . . . . . . . . . . . . . . . . . . . . . 197 --fpu (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 --header_context (compiler option) . . . . . . . . . . . . . . . . . . 172 --ihex (ielftool option). . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 --image_input (linker option) . . . . . . . . . . . . . . . . . . . . . . 198 --interwork (compiler option) . . . . . . . . . . . . . . . . . . . . . . 173 --keep (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 --legacy (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . 174 --log (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 --log_file (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . 199 --mangled_names_in_messages (linker option) . . . . . . . . 199 --map (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 --mfc (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . . . 175 --migration_preprocessor_extensions (compiler option) . . 175 --misrac_verbose (compiler option) . . . . . . . . . . . . . . . . . 159 --misrac_verbose (linker option) . . . . . . . . . . . . . . . . . . . . 190
--misrac1998 (compiler option) . . . . . . . . . . . . . . . . . . . . 159 --misrac1998 (linker option) . . . . . . . . . . . . . . . . . . . . . . . 190 --misrac2004 (compiler option) . . . . . . . . . . . . . . . . . . . . 159 --misrac2004 (linker option) . . . . . . . . . . . . . . . . . . . . . . . 190 --no_clustering (compiler option) . . . . . . . . . . . . . . . . . . . 176 --no_code_motion (compiler option) . . . . . . . . . . . . . . . . 176 --no_const_align (compiler option) . . . . . . . . . . . . . . . . . . 176 --no_cse (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . 177 --no_fragments (compiler option) . . . . . . . . . . . . . . . . . . . 177 --no_fragments (linker option) . . . . . . . . . . . . . . . . . . . . . 200 --no_guard_calls (compiler option) . . . . . . . . . . . . . . . . . . 177 --no_inline (compiler option) . . . . . . . . . . . . . . . . . . . . . . 178 --no_library_search (linker option) . . . . . . . . . . . . . . . . . . 201 --no_locals (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 201 --no_path_in_file_macros (compiler option) . . . . . . . . . . . 178 --no_remove (linker option) . . . . . . . . . . . . . . . . . . . . . . . 201 --no_scheduling (compiler option) . . . . . . . . . . . . . . . . . . 178 --no_tbaa (compiler option) . . . . . . . . . . . . . . . . . . . . . . . 179 --no_typedefs_in_diagnostics (compiler option) . . . . . . . . 179 --no_unaligned_access (compiler option) . . . . . . . . . . . . . 180 --no_unroll (compiler option) . . . . . . . . . . . . . . . . . . . . . . 180 --no_veneer (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 202 --no_warnings (compiler option) . . . . . . . . . . . . . . . . . . . 181 --no_warnings (linker option) . . . . . . . . . . . . . . . . . . . . . . 202 --no_wrap_diagnostics (compiler option) . . . . . . . . . . . . . 181 --no_wrap_diagnostics (linker option) . . . . . . . . . . . . . . . 202 --only_stdout (compiler option) . . . . . . . . . . . . . . . . . . . . 182 --only_stdout (linker option) . . . . . . . . . . . . . . . . . . . . . . . 203 --ose_load_module (linker option) . . . . . . . . . . . . . . . . . . 203 --output (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . 183 --output (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 --pi_veneer (linker option) . . . . . . . . . . . . . . . . . . . . . . . . 204 --place_holder (linker option) . . . . . . . . . . . . . . . . . . . . . . 204 --predef_macro (compiler option) . . . . . . . . . . . . . . . . . . . 183 --preinclude (compiler option) . . . . . . . . . . . . . . . . . . . . . 183 --preprocess (compiler option) . . . . . . . . . . . . . . . . . . . . . 184 --raw (ielfdump] option) . . . . . . . . . . . . . . . . . . . . . . . . . . 338 --redirect (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . 205 --remarks (compiler option) . . . . . . . . . . . . . . . . . . . . . . . 185
402
Index
--remarks (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . 205 --remove_section (iobjmanip option) . . . . . . . . . . . . . . . . 340 --rename_section (iobjmanip option) . . . . . . . . . . . . . . . . 340 --rename_symbol (iobjmanip option) . . . . . . . . . . . . . . . . 341 --replace (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . 327 --require_prototypes (compiler option) . . . . . . . . . . . . . . . 185 --section (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . 186 --section (ielfdump option) . . . . . . . . . . . . . . . . . . . . . . . . 338 --semihosting (linker option). . . . . . . . . . . . . . . . . . . . . . . 205 --separate_cluster_for_initialized_variables (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 --silent (compiler option) . . . . . . . . . . . . . . . . . . . . . . . . . 187 --silent (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . 327 --silent (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 --silent (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 --simple (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . 334 --srec (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 --srec-len (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . 335 --srec-s3only (ielftool option) . . . . . . . . . . . . . . . . . . . . . . 335 --strict_ansi (compiler option). . . . . . . . . . . . . . . . . . . . . . 187 --strip (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 --strip (iobjmanip option) . . . . . . . . . . . . . . . . . . . . . . . . . 341 --strip (linker option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 --symbols (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . 328 --thumb (compiler option). . . . . . . . . . . . . . . . . . . . . . . . . 187 --toc (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 --use_unix_directory_separators (compiler option). . . . . . 188 --verbose (iarchive option) . . . . . . . . . . . . . . . . . . . . . . . . 328 --verbose (ielftool option) . . . . . . . . . . . . . . . . . . . . . . . . . 335 --warnings_affect_exit_code (compiler option) . . . . 151, 188 --warnings_affect_exit_code (linker option) . . . . . . . . . . . 206 --warnings_are_errors (compiler option) . . . . . . . . . . . . . 188 --warnings_are_errors (linker option) . . . . . . . . . . . . . . . . 206 .bss (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .comment (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .cstart (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 .data (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 .data_init (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 .debug (ELF section). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .iar.debug (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . 320
.iar.dynexit (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 .intvec (section). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 .memattr.text (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 .noinit (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 .rel (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .rela (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .rodata (section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 .shstrtab (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .strtab (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 .symtab (ELF section) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320 @ (operator) placing at absolute address . . . . . . . . . . . . . . . . . . . . . . 132 placing in sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 _AEABI_PORTABILITY_LEVEL (preprocessor symbol) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 _AEABI_PORTABLE (preprocessor symbol) . . . . . . . . . 125 _Exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 _exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 _Exit, C99 extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 _Pragma (predefined symbol) . . . . . . . . . . . . . . . . . . . . . . 287 __ALIGNOF__ (operator) . . . . . . . . . . . . . . . . . . . . . . . . 223 __arm (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 237 __ARMVFP__ (predefined symbol) . . . . . . . . . . . . . . . . . 284 __ARM4M__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM4TM__ (predefined symbol) . . . . . . . . . . . . . . . . 284 __ARM5E__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM5__ (predefined symbol) . . . . . . . . . . . . . . . . . . . 284 __ARM6M__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM6SM__ (predefined symbol). . . . . . . . . . . . . . . . . 284 __ARM6__ (predefined symbol) . . . . . . . . . . . . . . . . . . . 284 __ARM7M__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __ARM7R__ (predefined symbol) . . . . . . . . . . . . . . . . . . 284 __asm (language extension) . . . . . . . . . . . . . . . . . . . . . . . 225 __BASE_FILE__ (predefined symbol) . . . . . . . . . . . . . . . 284 __big_endian (extended keyword) . . . . . . . . . . . . . . . . . . 237 __BUILD_NUMBER__ (predefined symbol) . . . . . . . . . 284 __close (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 __CLZ (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 262 __CORE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 284 __cplusplus (predefined symbol) . . . . . . . . . . . . . . . . . . . 284
403
__CPU_MODE__ (predefined symbol) . . . . . . . . . . . . . . 284 __DATE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 284 __disable_fiq (intrinsic function) . . . . . . . . . . . . . . . . . . . 262 __disable_interrupt (intrinsic function) . . . . . . . . . . . . . . . 263 __disable_irq (intrinsic function) . . . . . . . . . . . . . . . . . . . 263 __DLIB_FILE_DESCRIPTOR (configuration symbol) . . . 80 __DMB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 263 __DSB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 263 __embedded_cplusplus (predefined symbol) . . . . . . . . . . 284 __enable_fiq (intrinsic function) . . . . . . . . . . . . . . . . . . . . 264 __enable_interrupt (intrinsic function) . . . . . . . . . . . . . . . 264 __enable_irq (intrinsic function) . . . . . . . . . . . . . . . . . . . . 264 __exit (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 __FILE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 284 __fiq (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . . 237 __FUNCTION__ (predefined symbol) . . . . . . . . . . . 231, 285 __func__ (predefined symbol) . . . . . . . . . . . . . . . . . 231, 285 __gets, in stdio.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 __get_BASEPRI (intrinsic function) . . . . . . . . . . . . . . . . . 264 __get_CONTROL (intrinsic function) . . . . . . . . . . . . . . . 264 __get_CPSR (intrinsic function) . . . . . . . . . . . . . . . . . . . . 265 __get_FAULTMASK (intrinsic function) . . . . . . . . . . . . . 265 __get_interrupt_state (intrinsic function) . . . . . . . . . . . . . 265 __get_PRIMASK (intrinsic function) . . . . . . . . . . . . . . . . 265 __iar_maximum_atexit_calls . . . . . . . . . . . . . . . . . . . . . . . 53 __IAR_SYSTEMS_ICC__ (predefined symbol) . . . . . . . 285 __ICCARM__ (predefined symbol) . . . . . . . . . . . . . . . . . 285 __interwork (extended keyword) . . . . . . . . . . . . . . . . . . . 238 __intrinsic (extended keyword) . . . . . . . . . . . . . . . . . . . . . 238 __irq (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . . 238 __ISB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . . 266 __LDC (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 266 __LDCL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 266 __LDCL_noidx (intrinsic function) . . . . . . . . . . . . . . . . . 266 __LDC_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . . 266 __LDC2 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 266 __LDC2L (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 266 __LDC2L_noidx (intrinsic function) . . . . . . . . . . . . . . . . 266 __LDC2_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . 266
__LDREX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 267 __LINE__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 285 __little_endian (extended keyword) . . . . . . . . . . . . . . . . . 238 __LITTLE_ENDIAN__ (predefined symbol) . . . . . . . . . . 285 __low_level_init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 initialization phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 __low_level_init, customizing . . . . . . . . . . . . . . . . . . . . . . 76 __lseek (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 __MCR (intrinsic function). . . . . . . . . . . . . . . . . . . . . . . . 267 __MRC (intrinsic function). . . . . . . . . . . . . . . . . . . . . . . . 268 __nested (extended keyword) . . . . . . . . . . . . . . . . . . . . . . 239 __noreturn (extended keyword) . . . . . . . . . . . . . . . . . . . . 239 __no_init (extended keyword) . . . . . . . . . . . . . . . . . 143, 239 __no_operation (intrinsic function) . . . . . . . . . . . . . . . . . . 268 __open (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 __packed (extended keyword). . . . . . . . . . . . . . . . . . . . . . 240 __PRETTY_FUNCTION__ (predefined symbol). . . . . . . 285 __printf_args (pragma directive) . . . . . . . . . . . . . . . . 254, 356 __program_start (label) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 __QADD (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 268 __QADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 268 __QADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 269 __QASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 269 __QDADD (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 269 __QDOUBLE (intrinsic function) . . . . . . . . . . . . . . . . . . . 269 __QDSUB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 270 __QFlag (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 270 __QSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 271 __qsortbbl, C99 extension. . . . . . . . . . . . . . . . . . . . . . . . . 296 __QSUB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 270 __QSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 270 __QSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 270 __ramfunc (extended keyword). . . . . . . . . . . . . . . . . . . . . 240 executing in RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 __read (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 __ReportAssert (library function) . . . . . . . . . . . . . . . . . . . . 85 __REV (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 271 __REVSH (intrinsic function). . . . . . . . . . . . . . . . . . . . . . 271
404
Index
__root (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 241 __SADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 271 __SADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 271 __SASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 272 __scanf_args (pragma directive) . . . . . . . . . . . . . . . . 256, 356 __section_begin (extended operator) . . . . . . . . . . . . . . . . 223 __section_end (extended operator) . . . . . . . . . . . . . . . . . . 223 __section_size (extended operator) . . . . . . . . . . . . . . . . . . 223 __SEL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 272 __set_BASEPRI (intrinsic function) . . . . . . . . . . . . . . . . . 272 __set_CONTROL (intrinsic function) . . . . . . . . . . . . . . . . 272 __set_CPSR (intrinsic function) . . . . . . . . . . . . . . . . . . . . 273 __set_FAULTMASK (intrinsic function) . . . . . . . . . . . . . 273 __set_interrupt_state (intrinsic function) . . . . . . . . . . . . . 273 __set_PRIMASK (intrinsic function) . . . . . . . . . . . . . . . . 273 __SHADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 273 __SHADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 274 __SHASX (intrinsic function). . . . . . . . . . . . . . . . . . . . . . 274 __SHSAX (intrinsic function). . . . . . . . . . . . . . . . . . . . . . 274 __SHSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 274 __SHSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 274 __SMUL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 275 __SSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 275 __SSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 275 __SSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 275 __STC (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 276 __STCL (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 276 __STCL_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . 276 __STC_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . . 276 __STC2 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 276 __STC2L (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 276 __STC2L_noidx (intrinsic function) . . . . . . . . . . . . . . . . . 276 __STC2_noidx (intrinsic function) . . . . . . . . . . . . . . . . . . 276 __STDC_VERSION__ (predefined symbol) . . . . . . . . . . 285 __STDC__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 285 __STREX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 277 __swi (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 241 __SWP (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . . 277 __SWPB (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 277
__task (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . . 242 __thumb (extended keyword) . . . . . . . . . . . . . . . . . . . . . . 243 __TID__ (predefined symbol). . . . . . . . . . . . . . . . . . . . . . 286 __TIME__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . 285 __UADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 277 __UADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 277 __UASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 278 __UHADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 278 __UHADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 278 __UHASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 278 __UHSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 278 __UHSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 279 __ungetchar, in stdio.h . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 __UQADD8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 279 __UQADD16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 279 __UQASX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 280 __UQSAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 280 __UQSUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . 280 __UQSUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . 280 __USAX (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . . 280 __USUB8 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . . 281 __USUB16 (intrinsic function) . . . . . . . . . . . . . . . . . . . . . 281 __VA_ARGS__ (preprocessor extension) . . . . . . . . . . . . . 288 __VER__ (predefined symbol) . . . . . . . . . . . . . . . . . . . . . 286 __weak (extended keyword) . . . . . . . . . . . . . . . . . . . . . . . 243 __write (library function) . . . . . . . . . . . . . . . . . . . . . . . . . . 81 customizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 __write_array, in stdio.h . . . . . . . . . . . . . . . . . . . . . . . . . . 296 __write_buffered (DLIB library function). . . . . . . . . . . . . . 87
Numerics
32-bits (floating-point format) . . . . . . . . . . . . . . . . . . . . . 213 64-bits (floating-point format) . . . . . . . . . . . . . . . . . . . . . 214
405