Segger Embedded Studio Manual
Segger Embedded Studio Manual
Segger Embedded Studio Manual
Version: 2.20
Contents
Contents
Introduction ............................................................................................................................................................................................... 23
What is SEGGER Embedded Studio? ................................................................................................................................. 24
What we don't tell you ........................................................................................................................................................... 26
Getting Started ........................................................................................................................................................................... 27
Text conventions ....................................................................................................................................................................... 28
Release notes .............................................................................................................................................................................. 30
SEGGER Embedded Studio User Guide .......................................................................................................................................... 37
SEGGER Embedded Studio standard layout ................................................................................................................. 38
Menu bar ........................................................................................................................................................................ 39
Title bar ........................................................................................................................................................................... 40
Status bar ....................................................................................................................................................................... 41
Editing workspace ...................................................................................................................................................... 43
Docking windows ....................................................................................................................................................... 44
Dashboard ...................................................................................................................................................................... 46
SEGGER Embedded Studio help and assistance .......................................................................................................... 47
Creating and managing projects ....................................................................................................................................... 49
Solutions and projects .............................................................................................................................................. 50
Creating a project ....................................................................................................................................................... 53
Adding existing files to a project ........................................................................................................................ 54
Adding new files to a project ................................................................................................................................ 55
Removing a file, folder, project, or project link ............................................................................................. 56
Project macros ............................................................................................................................................................. 57
Building your application ...................................................................................................................................................... 59
Contents
Contents
Contents
Contents
Contents
Contents
Contents
10
Contents
11
Contents
12
Contents
13
Contents
14
Contents
15
Contents
16
Contents
17
Contents
18
Contents
19
Contents
20
Contents
21
Contents
22
Introduction
Introduction
This guide is divided into a number of sections:
Introduction
Covers installing SEGGER Embedded Studio on your machine and verifying that it operates correctly,
followed by a brief guide to the operation of the SEGGER Embedded Studio integrated development
environment, debugger, and other software supplied in the product.
ide_target_interfaces
Contains a description of the support for programming ARM microcontrollers.
23
Introduction
C/C++ Compiler
SEGGER Embedded Studio comes with pre-built versions of both GCC and Clang/LLVM C and C++ compilers
and assemblers. The GNU linker and librarian are also supplied to enable you to immediately begin developing
applications for ARM.
24
Introduction
25
Introduction
C programming guides
These are must-have books for any C programmer:
Kernighan, B.W. and Ritchie, D.M., The C Programming Language (2nd edition, 1988). Prentice-Hall,
Englewood Cliffs, NJ, USA. ISBN 0-13-110362-8.
The original C bible, updated to cover the essentials of ANSI C (1990 version).
Harbison, S.P. and Steele, G.L., C: A Reference Manual (second edition, 1987). Prentice-Hall, Englewood
Cliffs, NJ, USA. ISBN 0-13-109802-0.
A nice reference guide to C, including a useful amount of information on ANSI C. Co-authored by Guy
Steele, a noted language expert.
ANSI C reference
If you're serious about C programming, you may want to have the ISO standard on hand:
ISO/IEC 9899:1990, C Standard and ISO/IEC 9899:1999, C Standard. The standard is available from your
national standards body or directly from ISO at http://www.iso.ch/.
ARM microcontrollers
For ARM technical reference manuals, specifications, user guides and white papers, go to:
http://www.arm.com/Documentation.
LLVM/Clang
For the latest LLVM/Clang documentation to to:
http://www.llvm.org
26
Introduction
Getting Started
You will need to install a CPU support package:
Choose Tools > Package Manager
Choose the CPU support packages you wish to install and complete the dialog.
You will need to create a project:
Choose File > New Project
Select the appropriate Executable project type
Specify a location for the project
Complete the dialog selecting the appropriate Target Processor value
You will need to build the project:
Choose Build | Build 'Project'
To debug on the simulator
Choose Target | Connect | ARM Simulator
To debug on hardware
Choose Target | Connect | SEGGER J-Link
To start debugging
Choose Debug | Go
The debugger will stop the program at the main, you can now debug the application.
27
Introduction
Text conventions
Menus and user interface elements
When this document refers to any user interface element, it will do so in bold font. For instance, you will often
see reference to the Project Explorer, which is taken to mean the project explorer window. Similarly, you'll see
references to the Standard toolbar which is positioned at the top of the SEGGER Embedded Studio window, just
below the menu bar on Windows and Linux.
When you are directed to select an item from a menu in SEGGER Embedded Studio, we use the form menuname > item-name. For instance, File > Save means that you need to click the File menu in the menu bar and
then select the Save item. This form extends to items in sub-menus, so File > Open With Binary Editor has the
obvious meaning.
Keyboard accelerators
Frequently-used commands are assigned keyboard accelerators to speed up common tasks. SEGGER Embedded
Studio uses standard Windows and Mac OS keyboard accelerators wherever possible.
Windows and Linux have three key modifiers which are Ctrl, Alt, and Shift. For instance, Ctrl+Alt+P means that
you should hold down the Ctrl and Alt buttons whilst pressing the P key; and Shift+F5 means that you should
hold down the Shift key whilst pressing F5.
Mac OS has four key modifiers which are ? (command), ? (option), ? (control), and ? (shift). Generally there is a
one-to-one correspondence between the Windows modifiers and the Mac OS modifiers: Ctrl is ?, Alt is ?, and
Shift is ?. SEGGER Embedded Studio on Mac OS has its own set of unique key sequences using ? (control) that
have no direct Windows equivalent.
SEGGER Embedded Studio on Windows and Linux also uses key chords to expand the set of accelerators. Key
chords are key sequences composed of two or more key presses. For instance, the key chord Ctrl+T, D means
that you should type Ctrl+T followed by D; and Ctrl+K, Ctrl+Z means that you should type Ctrl+T followed by
Ctrl+Z. Mac OS does not support accelerator key chords.
28
Introduction
Whenever commands to and responses from the computer are mixed in the same example, the commands
(i.e. the items which you enter) will be presented in this typeface. For example, here is a dialog with the
computer using the format of the compilation command given above:
c:\code\examples>hcl -v myprog.c
The user types the text hcl -v myprog.c and then presses the enter key (which is assumed and is not shown); the
computer responds with the rest.
29
Introduction
Release notes
Version 2.20
Build
Added support for complex.h in C library.
New Cortex-M projects will contain references to the HardFaultHandler files.
Files within projects now build in parallel when multi-threaded building is enabled.
Added C++ cmath float functions.
Debug
Handle errors when memory cannot be accessed for backtracing, displaying variables and showing
disassembly.
Watch windows have optional columns to display address, size and type.
Watch windows can now contain sub-expressions of existing watched expressions.
Improved support for displaying variables with optimised code.
Added support for displaying C complex numbers.
Removed "Default" from "Target Interface Type" project property.
The "Target Connection" and "Target Interface Type" project properties are shown for new generic project
creation.
The target will auto connect on "Debug | Start" after a new project has been created.
Fixed crash with J-Link when backtracing and sp is not in valid memory.
Fixed debugger caching of breakpointed instructions when target not disconnected between debug
sessions.
Fixed errant stopped by Data Breakpoint output.
Added environment option "Show Data Tips In Text Editor".
Added the /opt/SEGGER/JLink/x86 directory to the Linux x86 J-Link shared library search path.
Fixed simulated ARM MRS and Thumb to ARM BLX instructions.
Total warning count now displayed on build completion.
Fixed SWO and MTB trace.
Fixed lack of error reporting when running out of hardware breakpoints and no flash breakpoint license.
Debugger now sets the initial and startup completion breakpoints before the user breakpoints are set.
RTT will not be enabled until the startup completion breakpoint has been hit.
Disassembler avoids the disassembling of literal pools.
Fixed memory leak in watch windows.
Improved debug support for IAR and Keil generated executables.
Updated shipped J-Link software to V5.12.
30
Introduction
IDE
Fixed Spaces In Square Brackets and Spaces In Parentheses text editor code formatting options.
Code formatter tool can now run on header files in project.
Fixed code formatting of a selection.
Fixed code formatting of a modified file.
Fixed disassembly window's font not updating until restart.
Fixed disassembly window's font not updating until restart.
Fixed Text Editor > Mouse Options > Alt+Left Click and Text Editor > Mouse Options > Ctrl+Left Click
environment options.
Fixed copying to clipboard in text editor resetting scaled font size.
Imported projects from uvproj(x) files now use the TargetName. Imported projects from mpw files now
use the uvproj(x) filename and the TargetName.
Changed Import Package Files to also import files referenced via $(StudioDir).
Fixed index.exe holding open header file handles after code completion and goto definition.
Fixed goto definition usage of Source Navigator.
The Space Before Parentheses text editor code formatting option is now taken into account when
generating code completion suggestions.
Removed documentation reference to unsupported -gcc command option.
Project explorer rather than disassembly window is now shown by default in debug perspective.
Licensing
Fixed problems caused by using different versions of jlink.dll for license checking and debugging.
Version 2.16
Build
Added keep attribute to section placement file.
C library functions are now declared weak enabling them to be overridden by user supplied equivalents.
Added missing C99 float and double precision math functions to C library.
Added VFPV4-D32 to "ARM FPU Type" project property and library build variants.
Debug
Added project property "Erase All" that requests a chip erase prior to download.
Fixed execution trace disassembly for Thumb mode with CortexA/CortexR devices.
Added "Debug Begin Script" and "Debug End Script" project properties.
Fixed setting J-Link multiple breakpoints when target is executing.
Added support for DCC debugio for CortexA/CortexR devices.
31
Introduction
ROM table not used by the debugger, J-Link supplied information is now used.
JTAG chain project properties modified to match J-Link descriptions.
Memory window now shows memory that cannot be accessed.
Added "Start From Entry Point Symbol" project property.
IDE
Added Window > Zoom and Window > Minimize menu options (OS X only).
Fixed creating folders of the same name as the parent folder.
Fixed crash using "Find References" on newly created project.
Fixed project property dialog forgetting previously modified properties on cancel.
Project property dialog now optionally prompts on cancel if properties have been modified.
JavaScript project properties now have a multi-line editor.
Fixed reading of XML files with a UTF-8 byte order mark.
Register descriptions may now contain UTF-8 characters.
Version 2.14
Build
Fixed dynamic folder path attribute only expanding macros if macro is right at the start of the string.
Fixed dynamic folder exclude attribute matching on a sub-string.
Added missing __clzsi2 function.
Added missing __ctzsi2 function.
Debug
Simulator implements bit-banding for Cortex-M0 simulations.
Fixed connecting to TI ARM335x devices.
Fixed bug when single stepping onto breakpoint caused the breakpoint to be deleted.
Fixed simulation of SMMLA and SMMLS instructions.
Added range selection to memory window.
Added save selection functions to memory window.
Added data tips to memory window.
The memory window's columns field now scales when changing width field.
The memory window now adds extra space between column 8 and 9 in 16 column mode.
Added "Thread Maximum" project property to limit the number of entries in the threads window.
Threads window now updates based on the "Startup Completion Point" status.
Threads window now selects threads.js script only from the active project.
Fixed statement single stepping with clang compiled code.
32
Introduction
IDE
Fixed problem causing available packages list download to fail.
IDE is now brought to the foreground when a file is opened from an external application.
Fixed code completion leaving PCH files in temporary directory.
Version 2.12
Build
All library projects that an executable project is dependent on are now added to the link.
Upgraded LLVM/Clang to version 3.7.0.
Updated the GCC/BINUTILS tools build to use GCC ARM Embedded 4.9-2015-q3-update source release.
Project property "Enable All Warnings" now adds -Wextra option.
Debug
Fixed problems disconnecting with active threads window.
Stopped unnecessary USB enumeration at startup when the Target > Background Scan for Debug Pod
Presence environment option is enabled.
Fixed the context menu displayed in the disassembly window.
Editing in the memory window now selects the next column for edit.
Added J-Link "Execute J-Link Commands On Connect" and "Execute J-Link Commands On Debug Start"
properties.
Simulator access to unimplemented address regions now produces an error.
Simulator implements bit-banding for Cortex-M3/Cortex-M4 simulations.
Simulator detects XN (execute never) memory regions for Cortex-M simulations.
Implemented a new memory window editor providing 'one click' editing.
Text view can now be edited in memory window.
Added automatic size and column modes to memory window.
Enhanced memory window data/text viewing options.
Added automatic refresh function to memory window.
Mouse, scroll wheel and keyboard can now be used to navigate memory in the memory window.
Added Unicode text viewing and editing when memory window is set to 16 or 32 bit widths.
TracePort and ETB trace interfaces implemented using J-Link STRACE API.
Fixed always rebuilding filenames containing $ characters.
33
Introduction
IDE
Fixed debug terminal horizontal scroll always returning to the start of line when the debugger is running.
Fixed drag and drop of .emProject files.
Fixed code editor undo after saving with the Text Editor > Save Options > Delete Trailing Space On
Save environment option enabled.
Added Text Editor > Programmer Assistance > Template Characters To Match option.
Changed implementation of code completion and source navigation to use external program index.
Fixed auto-recovery when file has been edited within IDE and also with an external editor.
Go To Definition (and other source code operations) work without Source Navigator assistence.
Go To Definition (and other source code operations) fixed when files contain c++ constructors/
destructors/operators.
Filenames in session files are now stored relative to the session file.
Fixed Find Extras > Find In editor context menu options not working on OS X.
Fixed layout of windows when using monitors with a resolution of 4K and above.
Fixed usage of clang and libclang (e.g. goto definition) on Windows 10.
Add support for opening IAR .eww files.
Opening a Keil .uvmpw file now creates one project file rather than multiple project files.
Fixed smart indentation when previous line is empty.
Version 2.10a
Build
Changed the default for "Allow Multiple Symbol Definition" to "Yes".
New projects will have RTT specific implementations of printf and puts. Existing projects can import
$(StudioDir)/samples/SEGGER_RTT_SES.c.
Debug
Fixed disassembly display from the elf file.
34
Introduction
IDE
Fixed file naming when file extension supplied to new file dialog.
Added c++11 keywords to code editor syntax coloring.
Added SEGGER style to code formatter choices.
Added support for Windows 10.
Assumes .S files are assembly code files.
Licensing
Detects old license strings.
Version 2.10
Build
Removed CROSSWORKS_ARM define from build.
Added memcpy_fast library function.
Fixed build log job counting on folder and file builds.
Fixed memory leak in project explorer.
Fix crash if F4 is held down during a large build.
Updated the GCC/BINUTILS tools build to use GCC ARM Embedded 4.9-2015-q2-update source release.
Added "CM0/CM0+/CM1 Has Small Multiplier" project property.
Added "V7A/V7R Has Integer Divide Instructions" project property and associated library build variants.
Reduced big endian library build variants to V4T, V7M and V7R only.
Default printf/scanf libraries are now int and no floating point support.
Debug
Default J-Link target interface type is SWD for all Cortex-M devices.
Debugger now drains RTT on breakpoint.
Added Exclude Flash Cache Range J-Link target property.
Memory access errors with J-Link are ignored.
Improved error message when connect and flash download fail.
Improved support for handling large memory regions in simulator.
Improved backtracing out of Cortex-M exception handlers.
35
Introduction
IDE
Fixed setting j-link "Best Possible" speed.
Fixed "File Exists" error when pasting cut/copied file in project explorer.
Fixed "Folder Name in use" error when creating folders with the same name as the parent folder.
Added Goto Declaration.
Fixed saving of read-only files when using Find References.
Added Code Formatting capability to text editor.
Property dialog group selection now shows only the selected group.
Fixed computing the filepath when pasting files between projects.
Misc improvements to new project wizard.
Project properties not displayed in project window by default.
No toolbars are now visible by default.
Startup Options > Allow Multiple SEGGER Embedded Studios environment option now defaults to Yes.
Package manager no longer displayed on first run.
Properties positioning in project explorer context menu now controlled by an environment property.
Project file is now saved prior to showing properties editor dialog.
Auto reload of project file when edited using the text editor.
Removed targets window and added "Target Connection" debugger project property.
Licensing
Fixed crash when attempting to install license with no j-link connected.
Fixed check when installing incorrect license on j-link.
Removed j-link firmware update test when license checking.
Evaluation code size limit changed to 32K.
Fixed crash when starting emStudio with J-Link Commander or GDB Server running.
36
37
38
Menu bar
The menu bar contains menus for editing, building, and debugging your program. You can navigate menus
using the keyboard or the mouse.
39
Title bar
The first item shown in the title bar is SEGGER Embedded Studio's name. Because SEGGER Embedded Studio
can be used to target different processors, the name of the target processor family is also shown, to help you
distinguish between instances of SEGGER Embedded Studio when debugging multi-processor or multi-core
systems.
The filename of the active editor follows SEGGER Embedded Studio's name; you can configure the presentation
of this filename as described below.
After the filename, the title bar displays status information on SEGGER Embedded Studio's state:
[building] SEGGER Embedded Studio is building a solution, building a project, or compiling a file.
[run] An application is running under control of SEGGER Embedded Studio's debugger.
[break] The debugger is stopped at a breakpoint.
[autostep] The debugger is single stepping the application without user interaction (autostepping).
40
Status bar
At the bottom of the window, the status bar contains useful information about the current editor, build status,
and debugging environment. The status bar is divided into two regions: one contains a set of fixed panels and
the other is used for messages.
Description
Insert/overwrite status
Read-only status
Build status
41
Caret position
Time panel
42
Editing workspace
The main area of SEGGER Embedded Studio is the editing workspace. It contains any files being edited, the online help system's HTML browser, and the Dashboard.
43
Docking windows
SEGGER Embedded Studio has a flexible docking system you can use to position windows as you like them. You
can dock windows in the SEGGER Embedded Studio window or in the four head-up display windows. SEGGER
Embedded Studio will remember the position of the windows when you leave the IDE and will restore them
when you return.
Window groups
You can organize SEGGER Embedded Studio windows into window groups. A window group has multiple
windows docked in it, only one of which is active at a time. The window group displays the active window's title
for each of the windows docked in the group.
Clicking on the window icons in the window group's header changes the active window. Hovering over a
docked window's icon in the header will display that window's title in a tooltip.
Perspectives
SEGGER Embedded Studio remembers the dock position and visibility of each window in each perspective. The
most common use for this is to lay your windows out in the Standard perspective, which is the perspective
used when you are editing and not debugging. When SEGGER Embedded Studio starts to debug a program,
it switches to the Debug perspective. You can now lay out your windows in this perspective and SEGGER
Embedded Studio will remember how you laid them them out. When you stop debugging, SEGGER Embedded
Studio will revert to the Standard perspective and that window layout for editing; when you return to Debug
perspective on the next debug session, the windows will be restored to how you laid them out in that for
debugging.
SEGGER Embedded Studio remembers the layout of windows, in all perspectives, such that they can be restored
when you run SEGGER Embedded Studio again. However, you may wish to revert back to the standard docking
positions; to do this:
Choose Window > Reset Window Layout.
44
Some customers are accustomed to having the Project Explorer on the left or the right, depending upon which
version of Microsoft Visual Studio they commonly use. To quickly switch the SEGGER Embedded Studio layout to
match your preferred Visual Studio setup:
Choose Window > Reverse Workspace Layout.
45
Dashboard
When SEGGER Embedded Studio starts, it presents the Dashboard, a collection of panels that provide useful
information, one-click loading of recent projects, and at-a-glance summaries of activity relevant to you.
Tasks
The Tasks panel indicates tasks you need to carry out before SEGGER Embedded Studio is fully functionalfor
instance, whether you need to activate SEGGER Embedded Studio, install packages, and so on.
Updates
The Updates panel indicates whether any packages you have installed are now out of date because a newer
version is available. You can install each new package individually by clicking the Install button under each
notification, or install all packages by clicking the Install all updates link at the bottom of the panel.
Projects
The Projects panel contains links to projects you have worked on recently. You can load a project by clicking the
appropriate link, or clear the project history by clicking the Clear List button. To manage the contents of the list,
click the Manage Projects link and edit the list of projects in the Recent Projects window.
News
The News panel summarizes the activity of any RSS and Atom feeds you have subscribed to. Clicking a link will
display the published article in an external web browser. You can manage your feed subscriptions to by clicking
the Manage Feeds link at the end of the News panel and pinning the feeds in the Favorites windowyou are
only subscribed to the pinned feeds.
Links
The Links panel is a handy set of links to your favorite websites. If you pin a link in the Favorites window, it
appears in the Links panel.
46
Tooltips
When you position the pointer over a button and keep it still, a small window displays a brief description of
the button and its keyboard shortcut, if it has one.
Status tips
In addition to tooltips, SEGGER Embedded Studio provides a longer description in the status bar when you
hover over a button or menu item.
Online manual
SEGGER Embedded Studio has links from all windows to the online help system.
The browser
Documentation pages are shown in the Browser.
To view the help text for a particular window or other user-interface element:
Click to select the item with which you want assistance.
Choose Help > Help or press F1.
47
The Next Topic and Previous Topic items in the Help menu, or the buttons on the Contents window toolbar,
help navigate through topics.
To search the online documentation, type a search phrase into the Search box on the Contents window toolbar.
48
49
Solutions
When you have created a solution, it is stored in a project file. Project files are text files, with the file extension
emProject, that contain an XML description of your project. See Project file format for a description of the
project-file format.
Projects
The projects you create within a solution have a project type SEGGER Embedded Studio uses to determine how
to build the project. The project type is selected when you use the New Project dialog. The available project
types depend on the SEGGER Embedded Studio variant you are using, but the following are present in most
SEGGER Embedded Studio variants:
Executable: a program that can be loaded and executed.
Externally Built Executable: an executable that was not built by SEGGER Embedded Studio.
Library: a group of object files collected into a single file (sometimes called an archive).
Object File: the result of a single compilation.
Staging: a project that will apply a user-defined command to each file in a project.
Combining: a project that can be used to apply a user-defined command when any files in a project
have changed.
50
Folders
Projects can contain folders, which are used to group related files. Automated grouping uses the files' extensions
to, for example, put all .c files in one folder, etc. Grouping also can be done manually by explicitly creating a
file within a folder. Note that these project folders do not map onto directories in the file system, they are used
solely to structure the display of content shown in the Project Explorer.
Source files
Source files are all the files used to build a product. These include source code files and also section-placement
files, memory-map files, and script files. All the source files you use for a particular product, or for a suite of
related products, are managed in a SEGGER Embedded Studio project. A project can also contain files that
are not directly used by SEGGER Embedded Studio to build a product but contain information you use during
development, such as documentation. You edit source files during development using SEGGER Embedded
Studio's built-in text editor, and you organize files into a target (described next) to define the build-system
inputs for creating the product.
The source files of your project can be placed in folders or directly in the project. Ideally, the paths to files
placed in a project should be relative to the project directory, but at times you might want to refer to a file in an
absolute location and this is supported by the project system.
When you add a file to a project, the project system detects whether the file is in the project directory. If a
file is not in the project directory, the project system tries to make a relative path from the file to the project
directory. If the file isn't relative to the project directory, the project system detects whether the file is relative to
the $(StudioDir) directory; if so, the filename is defined using $(StudioDir). If a file is not relative to the project
directory or to $(StudioDir), the full, absolute pathname is used.
The project system will allow (with a warning) duplicate files to be put into a project.
The project system uses a file's extension to determine the appropriate build action to perform on the file:
A file with the extension .c will be compiled by a C compiler.
A file with the extension .cpp or .cxx will be compiled by a C++ compiler.
A file with the extension .s or .asm will be compiled by an assembler.
A file with the object-file extension .o will be linked.
51
Solution links
You can create links to existing project files from a solution, which enables you to create hierarchical builds. For
example, you could have a solution that builds a library together with a stub test driver executable. You can
link to that solution from your current solution by right-clicking the solution node of the Project Explorer and
selecting Add Existing Project. Your current solution can then use the library built by the other project.
Session files
When you exit SEGGER Embedded Studio, details of your current session are stored in a session file. Session files
are text files, with the file extension emSession, that contain details such as which files you have opened in the
editor and what breakpoints you have set in the Breakpoint window.
52
Creating a project
You can create a new solution for each project or place multiple projects in an existing solution.
53
54
55
56
Project macros
You can use macros to modify the way the project system refers to files.
Macros are divided into four classes:
System macros defined by SEGGER Embedded Studio relay information about the environment, such as
paths to common directories.
Global macros are saved in the environment and are shared across all solutions and projects. Typically,
you would set up paths to libraries and any external items here.
Project macros are saved as project properties in the project file and can define values specific to the
solution or project in which they are defined.
Build macros are generated by the project system when you build your project.
System macros
System macros are defined by SEGGER Embedded Studio itself and as such are read-only. System macros can
be used in project properties, environment settings and to refer to files. See System macros list for the list of
System macros.
Global macros
To define a global macro:
1. Choose Project > Macros.
2. Select the Global tab.
3. Set the macro using the syntax name = replacement text.
Project macros
To define a project macro:
1. Choose Project > Macros.
2. Select the Project tab.
3. Select the solution or project to which the macro should apply.
4. Set the macro using the syntax name = replacement text.
Alternatively, you can set the project macros from the Properties window:
1. Select the appropriate solution/project in the Project Explorer.
57
2. In the Properties window's General Options group, select the Macros property.
3. Click the ellipsis button on the right.
4. Set the macro using the syntax name = replacement text.
Build macros
Build macros are defined by the project system for a build of a given project node. See Build macros list for the
list of build macros.
Using macros
You can use a macro for a project property or environment setting by using the $(macro) syntax. For example,
the Object File Name property has a default value of $(IntDir)/$(InputName)$(OBJ).
You can also specify a default value for a macro if it is undefined using the $(macro:default) syntax. For example,
$(MyMacro:0) would expand to 0 if the macro MyMacro has not been defined.
58
59
60
Selecting a configuration
To set the configuration that affects your building and debugging, use the combo box in the Project Explorer or
select Build > Set Active Build Configuration
Creating a configuration
To create your own configurations, select Build > Build Configurations to invoke the Configurations dialog. The
New button will produce a dialog allowing you to name your configuration. You can now specify the existing
configurations from which your new configuration will inherit values.
Deleting a configuration
You can delete a configuration by selecting it and clicking the Remove button. This deletion cannot be undone
or canceled, so beware.
61
Private configurations
Some configurations are defined purely for inheriting and, as such, should not appear in the Build combo box.
When you select a configuration in the Configuration dialog, you can choose to hide that configuration.
62
Project properties
For solutions, projects, folders, and files, properties can be defined that are used by the project system in
the build process. These property values can be viewed and modified by using the Properties window in
conjunction with the Project Explorer. As you select items in the Project Explorer, the Properties window will
list the set of relevant properties.
Some properties are only applicable to a given item type. For example, linker properties are only applicable to
a project that builds an executable file. However, other properties can be applied either at the file, project, or
solution project node. For example, a compiler property can be applied to a solution, project, or individual file.
By setting a property at the solution level, you enable all files of the solution to use that property's value.
63
Unique properties
A unique property has one value. When a build is done, the value of a unique property is the first one defined
in the project hierarchy. For example, the Treat Warnings As Errors property could be set to Yes at the solution
level, which would then be applicable to every file in the solution that is compiled, assembled, and linked. You
can then selectively define property values for other project items. For example, a particular source file may have
warnings you decide are allowable, so you set the Treat Warnings As Errors to No for that particular file.
Note that, when the Properties window displays a project property, it will be shown in bold if it has been
defined for unique properties. The inherited or default value will be shown if it hasn't been defined.
solution Treat Warnings As Errors = Yes
project1 Treat Warnings As Errors = Yes
file1 Treat Warnings As Errors = Yes
file2 Treat Warnings As Errors = No
project2 Treat Warnings As Errors = No
file1 Treat Warnings As Errors = No
file2 Treat Warnings As Errors = Yes
In the above example, the files will be compiled with these values for Treat Warnings As Errors:
project1/file1
Yes
project1/file2
No
project2/file1
No
project2/file2
Yes
64
Aggregate properties
An aggregating property collects all the values defined for it in the project hierarchy. For example, when a C
file is compiled, the Preprocessor Definitions property will take all the values defined at the file, project, and
solution levels. Note that the Properties window will not show the inherited values of an aggregating property.
solution Preprocessor Definitions = SolutionDef
project1 Preprocessor Definitions =
file1 Preprocessor Definitions =
file2 Preprocessor Definitions = File1Def
project2 Preprocessor Definitions = ProjectDef
file1 Preprocessor Definitions =
file2 Preprocessor Definitions = File2Def
In the above example, the files will be compiled with these preprocessor definitions:
project1/file1
SolutionDef
project1/file2
SolutionDef, File1Def
project2/file1
SolutionDef, ProjectDef
project2/file2
65
In the above example, the files will be compiled with these preprocessor definitions when in Debug
configuration
File
Setting
project1/file1
CommonSolutionDef, DebugSolutionDef
project1/file2
CommonSolutionDef,
DebugSolutionDef,CommonFile1Def, DebugFile1Def
project2/file1
66
project2/file2
and the files will be compiled with these Preprocessor Definitions when in Release configuration:
File
Setting
project1/file1
CommonSolutionDef, ReleaseSolutionDef
project1/file2
CommonSolutionDef, ReleaseSolutionDef,
CommonFile1Def
project2/file1
project2/file2
67
68
A corresponding section-placement file will refer to the memory segments of the memory-map file and will
list the sections to be placed in those segments. This is done by using a memory-segment name in the sectionplacement file that matches the corresponding memory-segment name in the memory-map file.
For example, a section-placement file that places a section called .stack in the SRAM segment and the .vectors
and .text sections in the FLASH segment would look like this:
<Root name="Flash Section Placement">
<MemorySegment name="FLASH" >
<ProgramSection name=".vectors" load="Yes" />
<ProgramSection name=".text" load="Yes" />
</MemorySegment>
<MemorySegment name="SRAM" >
<ProgramSection name=".stack" load="No" />
</MemorySegment>
</Root>
Note that the order of section placement within a segment is top down; in this example .vectors is placed at
lower addresses than .text.
The memory-map file and section-placement file to use for linkage can be included as a part of the project or,
alternatively, they can be specified in the project's linker properties.
You can create a new program section using either the assembler or the compiler. For the C/C++ compiler, this
can be achieved using __attribute__ on declarations. For example:
void foobar(void) __attribute__ ((section(".foo")));
69
This will allocate foobar in the section called .foo. Alternatively, you can specify the names for the code,
constant, data, and zeroed-data sections of an entire compilation unit by using the Section Options properties.
You can now place the section into the section placement file using the editor so that it will be located after the
vectors sections as follows:
<Root name="Flash Section Placement">
<MemorySegment name="FLASH">
<ProgramSection name=".vectors" load="Yes" />
<ProgramSection name=".foo" load="Yes" />
<ProgramSection name=".text" load="Yes" />
</MemorySegment>
<MemorySegment name="SRAM">
<ProgramSection name=".stack" load="No" />
</MemorySegment>
</Root>
If you are modifying a section-placement file that is supplied in the SEGGER Embedded Studio distribution, you
will need to import it into your project using the Project Explorer.
Sections containing code and constant data should have their load property set to Yes. Some sections don't
require any loading, such as stack sections and zeroed-data sections; such sections should have their load
property set to No.
Some sections that are loaded then need to be copied to sections that aren't yet loaded. This is required for
initialized data sections and to copy code from slow memory regions to faster ones. To do this, the runin
attribute should contain the name of a section in the section-placement file to which the section will be copied.
For example, initialized data is loaded into the .data_load section and then is copied into the .data_run section
using:
<Root name="Flash Section Placement">
<MemorySegment name="FLASH">
<ProgramSection name=".vectors" load="Yes" />
<ProgramSection name=".text" load="Yes" />
<ProgramSection name=".data_load" load="Yes" runin="data_run" />
</MemorySegment>
<MemorySegment name="SRAM">
<ProgramSection name=".data_run" load="No" />
<ProgramSection name=".stack" load="No" />
</MemorySegment>
</Root>
The startup code will need to copy the contents of the .data_load section to the .data_run section. To enable
this, symbols are generated marking the start and end addresses of each section. For each section, a start symbol
called __section-name_start__ and an end symbol called __section-name_end__ are generated. These symbols
can be used to copy the sections from their load positions to their run positions.
For example, the .data_load section can be copied to the data_run section using the following call to memcpy.
/* Section image located in flash */
extern const unsigned char __data_load_start__[];
extern const unsigned char __data_load_end__[];
70
71
72
73
To configure Subversion:
1. Choose Tools > Options or press Alt+,.
2. Select the Source Control category in the options dialog.
3. Set the Executable property of the Subversion Options group to point to Subversion svn command. On
Windows operating systems, the Subversion command is svn.exe.
To configure Git:
1. Choose Tools > Options or press Alt+,.
2. Select the Source Control category in the options dialog.
3. Set the Executable property of the Git Options group to point to Git git command. On Windows
operating systems, the Git command is git.exe.
To configure Mercurial:
1. Choose Tools > Options or press Alt+,.
2. Select the Source Control category in the options dialog.
3. Set the Executable property of the Mercurial Options group to point to Git hg command. On Windows
operating systems, the Git command is hg.exe.
74
User credentials
You can set the credentials that the source-control system uses, for commands that require credentials, using
VCS > Options > Configure. From here you can set the user name and password. These details are saved to the
session file (the password is encrypted) so you won't need to specify this information each time the project is
loaded.
Note
SEGGER Embedded Studio has no facility to create repositories from scratch, nor to clone, pull, or checkout
repositories to a working copy: it is your responsibility to create a working copy outside of SEGGER Embedded
Studio using your selected command-line client or Windows Explorer extension.
The "Tortoise" products are a popular set of tools to provide source-control facilities in the Windows shell. Use
Google to find TortoiseSVN, TortoiseGit, and TortoiseHG and see if you like them.
75
76
Source-control operations
Source-control operations can be performed on single files or recursively on multiple files in the Project
Explorer hierarchy. Single-file operations are available on the Source Control toolbar and on the text editor's
shortcut menu. All operations are available using the VCS menu. The operations are described in terms of the
Project Explorer shortcut menu.
77
Note
Files are scheduled to be added to source control and will only be committed to source control (and seen by
others) when you commit the file.
Enabling the VCS > Options > Add Immediately option will bypass the dialog and immediately add (but not
commit) the files.
78
Updating files
To update files from source control:
1. In the Project Explorer, select the file to update. If you select a folder, project, or solution, any eligible
child items will also be updated from source control.
2. choose Source Control > Update or press Ctrl+R, U.
3. The dialog will list the files that can be updated.
4. In that dialog, you can deselect any files you don't want to update from source control.
5. Click Update.
Note
Enabling the VCS > Options > Update Immediately option will bypass the dialog and immediately update the
files.
79
Committing files
To commit files:
1. In the Project Explorer, select the file to commit. If you select a folder, project, or solution, any eligible
child items will also be committed.
2. Choose Source Control > Commit or press Ctrl+R, C.
3. The dialog will list the files that can be committed.
4. In that dialog, you can deselect any files you don't want to commit and enter an optional comment.
5. Click Commit.
Note
Enabling the VCS > Options > Commit Immediately option will bypass the dialog and immediately commit the
files without a comment.
80
Reverting files
To revert files:
1. In the Project Explorer, select the file to revert. If you select a folder, project, or solution, any eligible child
items will also be reverted.
2. Choose Source Control > Revert or press Ctrl+R, V.
3. The dialog will list the files that can be reverted.
4. In that dialog, you can deselect any files you don't want to revert.
5. Click Revert.
Note
Enabling the VCS > Options > Revert Immediately option will bypass the dialog and immediately revert files.
81
Locking files
To lock files:
1. In the Project Explorer, select the file to lock. If you select a folder, project, or solution, any eligible child
items will also be locked.
2. Choose Source Control > Lock or press Ctrl+R, L.
3. The dialog will list the files that can be locked.
4. In that dialog, you can deselect any files you don't want to lock and enter an optional comment.
5. Click Lock.
Note
Enabling the VCS > Options > Lock Immediately option will bypass the dialog and immediately lock files
without a comment.
82
Unlocking files
To unlock files:
1. In the Project Explorer, select the file to lock. If you select a folder, project, or solution, any eligible child
items will also be unlocked.
2. Choose Source Control > Unlock or press Ctrl+R, N.
3. The dialog will list the files that can be unlocked.
4. In that dialog, you can deselect any files you don't want to unlock.
5. Click Unlock.
Note
Enabling the VCS > Options > Unlock Immediately option will bypass the dialog and immediately unlock files.
83
Note
Files are scheduled to be removed from source control and will still be and seen by others, giving you the
opportunity to revert the removal. When you commit the file, the file is removed from source control.
Enabling the VCS > Options > Remove Immediately option will bypass the dialog and immediately remove (but
not commit) files.
84
85
Source-control properties
When a file in the project is in source control, the Properties window shows the following properties in the
Source Control Options group:
Property
Description
last Author
Path: Relative
Path: Repository
Provider
Provider Status
Revision: Local
Revision: Remote
Status: In Conflict?
Status: Locked?
If Yes, the file is lock by you; if No, the file is not locked.
Status: Modified?
86
Subversion provider
The Subversion source-control provider has been tested with SVN 1.4.3.
Provider-specific options
The following environment options are supported:
Property
Description
Executable
Lock Supported
Authentication
Show Updates
Command
Commit
Update
87
Revert
Resolved
Lock
Unlock
Add
Remove
88
CVS provider
The CVS source-control provider has been tested with CVSNT 2.5.03. The CVS source-control provider uses the
CVS rls command to browse the repositorythis command is implemented in CVS 1.12 but usage of . as the
root of the module name is not supported.
Provider-specific options
The following environment options are supported:
Property
Description
CVSROOT
Edit/Unedit Supported
Executable
Login/Logout Required
Source-control operations
The SEGGER Embedded Studio source-control operations have been implemented using CVS commands. There
are no multiple-file operations, each operation is done on a single file and committed as part of the operation.
Operation
Command
Get Status
Get Latest
89
Check Out
Check In
90
Package management
Additional target-support functions can be added to, and removed from, SEGGER Embedded Studio with
packages.
A SEGGER Embedded Studio package is an archive file containing a collection of target-support files. Installing
a package involves copying the files it contains to an appropriate destination directory and registering the
package with SEGGER Embedded Studio's package system. Keeping target-support files separate from the
main SEGGER Embedded Studio installation allows us to support new hardware and issue bug fixes for existing
hardware-support files between SEGGER Embedded Studio releases, and it allows third parties to develop their
own support packages.
Installing packages
Use the Package Manager to automate the download, installation, upgrade and removal of packages.
91
92
Installing a package
The package-installation operation downloads a package to $(PackagesDir)/downloads, if it has not been
downloaded already, and unpacks the files contained within the package to their destination directory.
To install a package:
1. Choose Tools > Packages > Install Packages (this is equivalent to choosing Tools > Manage Packages
and setting the status filter to Display Not Installed).
2. Select the package or packages you wish to install.
3. Right-click the selected packages and choose Install Selected Packages from the shortcut menu.
4. Click Next; you will be see the actions the Package Manager is about to carry out.
5. Click Next and the Package Manager will install the selected packages.
6. When installation is complete, click Finish to close the Package Manager.
Updating a package
The package-update operation first removes existing package files, then it downloads the updated package to
$(PackagesDir)/downloads and unpacks the files contained within the package to their destination directory.
To update a package:
1. Choose Tools > Packages > Update Packages (this is equivalent to clicking Tools > Package Manager
and setting the status filter to Display Updates).
2. Select the package or packages you wish to update.
3. Right-click the selected packages and choose Update Selected Packages from the shortcut menu.
4. Click Next; you will see the actions the Package Manager is about to carry out.
5. Click Next and the Package Manager will update the package(s).
6. When the update is complete, click Finish to close the Package Manager.
Removing a package
The package-remove operation removes all the files that were extracted when the package was installed.
93
To remove a package:
1. Choose Tools > Packages > Remove Packages (this is equivalent to choosing Tools > Package Manager
and setting the status filter to Display Installed).
2. Select the package or packages you wish to remove.
3. Right-click the selected packages and choose Remove Selected Packages from the shortcut menu.
4. Click Next; you will see the actions the Package Manager is about to carry out.
5. Click Next and the Package Manager will remove the package(s).
6. When the operation is complete, click Finish to close the Package Manager.
Reinstalling a package
The package-reinstall operation carries out a package-remove operation followed by a package-install
operation.
To reinstall a package:
1. Choose Tools > Packages > Reinstall Packages (this is equivalent to choosing Tools > Package Manager
and setting the status filter to Display Installed).
2. Select the package or packages you wish to reinstall.
3. Right-click the packages to reinstall and choose Reinstall Selected Packages from the shortcut menu.
4. Click Next; you will see the actions the Package Manager is about to carry out.
5. Click Next and the Package Manager will reinstall the packages.
6. When the operation is complete, click Finish to close the Package Manager.
94
95
Project explorer
The Project Explorer is the user interface of the SEGGER Embedded Studio project system. It organizes your
projects and files and provides access to the commands that operate on them. A toolbar at the top of the
window offers quick access to commonly used commands for the selected project node or the active project.
Right-click to reveal a shortcut menu with a larger set of commands that will work on the selected project node,
ignoring the active project.
The selected project node determines what operations you can perform. For example, the Compile operation
will compile a single file if a file project node is selected; if a folder project node is selected, each of the files in
the folder are compiled.
You can select project nodes by clicking them in the Project Explorer. Additionally, as you switch between files
in the editor, the selection in the Project Explorer changes to highlight the file you're editing.
Left-click operations
The following operations are available in the Project Explorer with a left-click of the mouse:
Action
Description
Single click
Double click
Toolbar commands
The following buttons are on the toolbar:
Button
Description
Add a new file to the active project using the New File
dialog.
Add existing files to the active project.
96
For solutions:
Item
Description
Paste
Remove
Rename
Save Solution As
Properties
97
For projects:
Item
Description
Link
Debugging Commands
Memory-Map Commands
For Executable project types that don't have memorymap files in the project and have the memory-map file
project property set, there are commands to view the
memory-map file and to import it into the project.
Section-Placement Commands
For Executable project types that don't have sectionplacement files in the project but have the sectionplacement file project property set, there are
commands to view the section-placement file and to
import it into the project.
Target Processor
New Folder
Cut
Copy
Paste
Remove
Rename
98
Properties
For folders:
Item
Description
New Folder
Cut
Copy
Paste
Remove
Rename
Compile
Properties
For files:
Item
Description
Open
Edit the file with the default editor for the file's type.
Open With
Compile
Export Build
Disassemble
Preprocess
Cut
99
Copy
Remove
Import
Properties
100
Description
A C or C++ structure or a C++ namespace.
A C++ class.
A C++ member function declared private or a
function declared with static linkage.
A C++ member function declared protected.
A C++ member function declared public or a
function declared with extern linkage.
A C++ member variable declared private or a
variable declared with static linkage.
A C++ member variable declared protected.
A C++ member variable declared public or a variable
declared with extern linkage.
101
102
References window
The References window shows the results of the last Find References operation. The Find References facility
is closely related to the Source Navigator in that it indexes your project and searches for references within the
active source code regions.
103
User interface
Button
Description
Group symbols by source filename.
Group symbols by symbol type (equates, functions,
labels, sections, and variables).
Group symbols by the section where they are defined.
Move the insertion point to the statement that defined
the symbol.
Select columns to display.
The main part of the Symbol Browser displays each symbol (both external and static) that is linked into an
application. SEGGER Embedded Studio displays the following icons to the left of each symbol:
Icon
Description
Private Equate A private symbol not defined relative to
a section.
Public Equate A public symbol that is not defined
relative to a section.
Private Function A private function symbol.
Public Function A public function symbol.
Private Label A private data symbol, defined relative to
a section.
Public Label A public data symbol, defined relative to a
section.
Section A program section.
104
105
The Cycle Grouping icon will change to indicate that the Symbol Browser is grouping symbols by section.
When you group symbols by type, each symbol is classified as one of the following:
An Equate has an absolute value and is not defined as relative to, or inside, a section.
A Function is defined by a high-level code sequence.
A Variable is defined by a high-level data declaration.
A Label is defined by an assembly language module. Label is also used when high-level modules are
compiled with debugging information turned off.
When you group symbols by source file, each symbol is grouped underneath the source file in which it is
defined. Symbols that are absolute, are not defined within a source file, or are compiled without debugging
information, are grouped beneath (Unknown).
106
high-level language symbols with an underscore character, so the variable extern int u or the function
void fn(void) have low-level symbol names _u and _fn. The Symbol Browser uses the low-level symbol
name when displaying and filtering, so you must type the leading underscore to match high-level symbols.
Watching symbols
If a symbol's range and type is known, you can add it to the most recently opened Watch window or Memory
window.
107
What function uses the most code space? What requires the most data space?
1. Choose Navigate > Symbol Browser or press Ctrl+Alt+Y.
2. In the Grouping button menu on the Symbol Browser toolbar, select Group By Type.
3. Ensure the Size field is checked in the Field Chooser button's menu.
4. Ensure that the filter on the Symbol Browser toolbar is empty.
5. Click on the Size field in the header to sort by data size.
6. The sizes of variables and of functions are shown in separate lists.
108
Each bar represents an entire memory segment. Green represents the area of the segment that contains code or
data.
109
Each bar represents an entire memory segment. Green represents the area of the segment that contains the
program section.
110
111
Bookmarks window
The Bookmarks window contains a list of bookmarks that are set in the project. The bookmarks are stored in the
session file associated with the project and persist across runs of SEGGER Embedded Studioif you remove the
session file, the bookmarks associated with the project are lost.
User interface
Button
Description
Toggle a bookmark at the insertion point in the active
editor. Equivalent to choosing Edit > Bookmarks >
Toggle Bookmark or pressing Ctrl+F2.
Go to the previous bookmark in the bookmark list.
Equivalent to choosing Edit > Bookmarks > Previous
Bookmark or pressing Alt+Shift+F2.
Go to the next next bookmark in the bookmark list.
Equivalent to choosing Edit > Bookmarks > Next
Bookmark or pressing Alt+F2.
Clear all bookmarksyou confirm the action using a
dialog. Equivalent to choosing Edit > Bookmarks >
Clear All Bookmarks or pressing Ctrl+K, Alt+F2.
Selects the fill color for newly created bookmarks.
Double-clicking a bookmark in the bookmark list moves focus to the the bookmark.
You can set bookmarks with the mouse or using keystrokessee Using bookmarks.
112
113
Basic editing
This section is a whirlwind tour of the basic editing features SEGGER Embedded Studio's code editor provides.
Whether you are editing code, HTML, or plain text, the code editor is just like many other text editors or word
processors. For code that is part of a project, the project's programming language support provides syntax
highlighting (colorization), indentation, and so on.
This section is not a reference for everything the code editor provides; for that, look in the following sections.
114
Description
Up
Down
Left
Right
Home
End
PageUp
PageDown
Ctrl+Home
Ctrl+End
Ctrl+Left
Ctrl+Right
SEGGER Embedded Studio offers additional movement keystrokes, though most users are more comfortable
using repeated simple keystrokes to accomplish the same thing:
Keystroke
Description
Alt+Up
Alt+Down
Alt+Home
Alt+End
Ctrl+Up
115
Ctrl+Down
If you are editing source code, the are source-related keystrokes too:
Keystroke
Description
Ctrl+PgUp
Ctrl+PgDn
116
Adding text
The editor has two text-input modes:
Insertion mode: As you type on the keyboard, text is entered at the insertion point and any text to the
right of the insertion point is shifted along. A visual indication of insertion mode is that the cursor is a
flashing line.
Overstrike mode: As you type on the keyboard, text at the insertion point is replaced with your typing. A
visual indication of insertion mode is that the cursor is a flashing block.
Insert and overstrike modes are common to all editors: if one editor is in insert mode, all editors are in insert
mode. To configure the cursor appearance, choose Tools > Options.
117
Deleting text
The text editor supports the following common editing keystrokes:
Keystroke
Description
Backspace
Delete
Ctrl+Backspace
Ctrl+Delete
118
119
120
121
Searching
To find text in the current file:
1. Press Ctrl+F.
2. Enter the string to search for.
As you type, the editor searches the file for a match. The pop-up shows how many matches are in the current file.
To move through the matches while the Find box is still active, press Tab or F3 to move to the next match and
Shift+Tab or Shift+F3 to move to the previous match.
If you press Ctrl+F a second time, SEGGER Embedded Studio pops up the standard Find dialog to search the file.
If you wish to bring up the Find dialog without pressing Ctrl+F twice, choose Search > Find.
122
Advanced editing
You can do anything using its basic code-editing features, but the SEGGER Embedded Studio text editor has a
host of labor-saving features that make editing programs a snap.
This section describes the code-editor features intended to make editing source code easier.
123
To increase indentation:
Select the text to indent.
Choose Selection > Increase Line Indent or press Tab.
To decrease indentation:
Select the text to indent.
Choose Selection > Decrease Line Indent or press Shift+Tab.
The indentation size can be changed in the Language Properties pane of the editor's Properties window, as can
all the indent-related features listed below.
124
125
126
127
Using bookmarks
To edit a document elsewhere and then return to your current location, add a bookmark. The Bookmarks
window maintains a list of the bookmarks set in source files see Bookmarks window.
To place a bookmark:
1. Move the insertion point to the line you wish to bookmark.
2. Choose Edit > Bookmarks > Toggle Bookmark or press Ctrl+F2.
A bookmark symbol appears next to the line in the indicator margin to show the bookmark is set.
To remove a bookmark:
1. Move the insertion point to the line containing the bookmark.
2. Choose Edit > Bookmarks > Toggle Bookmark or press Ctrl+F2.
The bookmark symbol disappears, indicating the bookmark is no longer set.
128
Menu
Description
Ctrl+F2
Ctrl+K, 0
F2
Shift+F2
Ctrl+Q, F2
Ctrl+Q, Shift+F2
Edit > Bookmarks > Last Bookmark Move the insertion point to the last
In Document
bookmark in the document.
Ctrl+K, F2
Alt+F2
Alt+Shift+F2
Ctrl+Q, Alt+F2
Ctrl+Q, Alt+Shift+F2
Edit > Bookmarks > Last Bookmark Move the insertion point to the last
bookmark in the Bookmarks list.
Ctrl+K, Alt+F2
129
130
If the search will be case sensitive, set the Match case option.
If the search will be for a whole wordi.e., there will be whitespace, such as spaces or the beginning or
end of the line, on both sides of the string being searched forset the Match whole word option.
If the search string is a regular expression, set the Use regular expression option.
Click the Find All button to find all occurrences of the string in the specified files, or click the Bookmark
All button to bookmark all the occurrences of the string in the specified files.
131
132
133
Mouse-click accelerators
SEGGER Embedded Studio provides a number of mouse-click accelerators in the editor that speed access to
commonly used functions. The mouse-click accelerators are user configurable using Tools > Options.
Default
Left
Shift+Left
Ctrl+Left
Select word.
Alt+Left
Execute Go To Definition.
Middle
No action.
Shift+Middle
Ctrl+Middle
No action.
Alt+Middle
Right
Shift+Right
No action.
Ctrl+Right
No action.
Alt+Right
Configuring Mac OS X
On Mac OS X you must configure the mouse to pass middle clicks and right clicks to the application if you wish
to use mouse-click accelerators in SEGGER Embedded Studio. Configure the mouse preferences in the Mouse
control panel in Mac OS X System Preferences to the following:
134
135
Regular expressions
The editor can search and replace text using regular expressions. A regular expression is a string that uses
special characters to describe and reference patterns of text. The regular expression system used by the editor
is modeled on Perl's regexp language. For more information on regular expressions, see Mastering Regular
Expressions, Jeffrey E F Freidl, ISBN 0596002890.
Description
\d
\D
\s
\S
\w
\W
[c]
\c
\a
\f
\n
\r
\t
\v
\xhhhh
136
{n}
{n,}
{,m}
{n,m}
Beginning of line.
End of line.
\b
Word boundary.
\B
Non-word boundary.
(e)
Capture expression e.
\n
Examples
The following regular expressions can be used with the editor's search-and-replace operations. To use the
regular expression mode, the Use regular expression checkbox must be set in the search-and-replace dialog.
Once enabled, regular expressions can be used in the Find what search string. The Replace With strings can use
the "n" back-reference string to reference any captured strings.
"Find what"
"Replace With"
Description
Search for any-length string
containing one or more word
characters beginning with the
character u and ending in the
character d.
u\w.d
^.*;$
(typedef.+\s+)(\S+);
137
Locals window
The Locals window displays a list of all variables that are in scope of the selected stack frame in the Call Stack.
The Locals window has a toolbar and a main data display.
Button
Description
Display the selected item in binary.
Display the selected item in octal.
Display the selected item in decimal.
Display the selected item in hexadecimal.
Display the selected item as a signed decimal.
Display the selected item as a character or Unicode
character.
Set the range displayed in the active Memory window
to span the memory allocated to the selected item.
Sort variables alphabetically by name.
Sort variables numerically by address or register
number (default).
138
or
Click the item to change.
On the Locals window toolbar, select the desired display format.
139
Globals window
The Globals window displays a list of all variables that are global to the program. The operations available on the
entries in this window are the same as the Watch window, except you cannot add or delete variables from the
Globals window.
Description
Display the selected item in binary.
Display the selected item in octal.
Display the selected item in decimal.
Display the selected item in hexadecimal.
Display the selected item as a signed decimal.
Display the selected item as a character or Unicode
character.
Set the range displayed in the active Memory window
to span the memory allocated to the selected item.
Sort variables alphabetically by name.
Sort variables numerically by address or register
number (default).
140
141
Watch window
The Watch window provides a means to evaluate expressions and to display the results of those expressions.
Typically, expressions are just the name of a variable to be displayed, but they can be considerably more
complex; see Debug expressions. Note: expressions are always evaluated when your program stops, so the
expression you are watching is the one that is in scope of the stopped program position.
The Watch window is divided into a toolbar and the main data display.
Button
Description
Display the selected item in binary.
Display the selected item in octal.
Display the selected item in decimal.
Display the selected item in hexadecimal.
Display the selected item as a signed decimal.
Display the selected item as a character or Unicode
character.
Set the range displayed in the active Memory window
to span the memory allocated to the selected item.
Sort the watch items alphabetically by name.
Sort the watch items numerically by address or register
number (default).
Remove the selected watch item.
Remove all the watches.
Right-clicking a watch item shows a shortcut menu with commands that are not available from the toolbar.
Button
Description
View pointer or array as a null-terminated string.
View pointer or array as an array.
View pointer value.
Set watch value to zero.
Set watch value to one.
142
Filename
The filename context of the watch item.
Line number
The line number context of the watch item.
(Name)
The name of the watch item.
Address
The address or register of the watch item.
Expression
The debug expression of the watch item.
Previous Value
The previous watch value.
Size In Bytes
The size of the watch item in bytes.
Type
The type of the watch item.
Value
The value of the watch item.
143
144
Register window
The Register windows show the values of both CPU registers and the processor's special function or peripheral
registers. Because microcontrollers are becoming very highly integrated, it's not unusual for them to have
hundreds of special function registers or peripheral registers, so SEGGER Embedded Studio provides four
register windows. You can configure each register window to display one or more register groups for the
processor being debugged.
A Register window has a toolbar and a main data display.
Button
Description
Display the CPU, special function register, and
peripheral register groups.
Display the CPU registers.
Hide the CPU registers.
Force-read a register, ignoring the access property of
the register.
Update the selected register group.
Set the active memory window to the address and size
of the selected register group.
145
The register state of the currently selected thread using the the Threads window.
The register state you supplied with the Debug > Locate operation.
146
Enter the new value for the register. Prefix hexadecimal numbers with 0x, binary numbers with 0b, and
octal numbers with 0.
or
Right-click the value of the register to modify.
From the shortcut menu, choose one of the commands to modify the register value.
Modifying the saved register value of a function or thread may not be supported.
147
Memory window
The Memory window shows the contents of the connected target's memory areas and allows the memory to be
edited. SEGGER Embedded Studio provides four memory windows, you can configure each memory window to
display different memory ranges.
The Memory window has a toolbar and a data display/edit area
Field/Button
Description
Address
Size
Columns
148
Description
Up
Down
Left
Right
Home
End
PageUp
149
PageDown
Ctrl+E
Editing memory
To edit memory, simply move the cursor to the data or text entry you want to modify and start typing. The
memory entry will be written and read back as you type.
Description
Address Order
Auto Evaluate
Auto Refresh
Save As
Load From
Display formats
You can set the Memory window to display 8-bit, 16-bit, and 32-bit values that are formatted as hexadecimal,
decimal, unsigned decimal, octal, or binary. You can also specify how many columns to display.
150
151
Breakpoints window
The Breakpoints window manages the list of currently set breakpoints on the solution. Using the Breakpoints
window, you can:
Enable, disable, and delete existing breakpoints.
Add new breakpoints.
Show the status of existing breakpoints.
Breakpoints are stored in the session file, so they will be remembered each time you work on a particular
project. When running in the debugger, you can set breakpoints on assembly code addresses. These low-level
breakpoints appear in the Breakpoints window for the duration of the debug run but are not saved when you
stop debugging.
When a breakpoint is reached, the matching breakpoint is highlighted in the Breakpoints window.
Description
Create a new breakpoint using the New Breakpoint
dialog.
Toggle the selected breakpoint between enabled and
disabled states.
Remove the selected breakpoint.
Move the insertion point to the statement where the
selected breakpoint is set.
Delete all breakpoints.
Disable all breakpoints.
Enable all breakpoints.
Create a new breakpoint group and makes it active.
The main part of the Breakpoints window shows what breakpoints are set and the state they are in. You can
organize breakpoints into folders, called breakpoint groups.
SEGGER Embedded Studio displays these icons to the left of each breakpoint:
Icon
Description
152
To delete a breakpoint:
In the Breakpoints window, click the breakpoint to delete.
From the Breakpoints window toolbar, click the Delete Breakpoint} button.
153
Breakpoint groups
Breakpoints are divided into breakpoint groups. You can use breakpoint groups to specify sets of breakpoints
that are applicable to a particular project in the solution or for a particular debug scenario. Initially, there is a
single breakpoint group, named Default, to which all new breakpoints are added.
154
155
Description
Move the insertion point to where the call was made
to the selected frame.
Set the debugger context to the selected stack frame.
Move the debugger context down one stack to the
called function.
Move the debugger context up one stack to the calling
function.
Select the fields to display for each entry in the call
stack.
Set the debugger context to the most recent stack
frame and move the insertion point to the currently
executing statement.
The main part of the Call Stack window displays each unfinished function call (active stack frame) at the point
when program execution halted. The most recent stack frame is displayed at the bottom of the list and the
oldest is displayed at the top of the list.
SEGGER Embedded Studio displays these icons to the left of each function name:
Icon
Description
Indicates the stack frame of the current task.
Indicates the stack frame selected for the debugger
context.
Indicates that a breakpoint is active and when the
function returns to its caller.
These icons can be overlaid to show, for instance, the debugger context and a breakpoint on the same stack
frame.
156
157
On the Debug Location toolbar, click the Up One Stack Frame button.
or
Press Alt+-.
The debugger moves the insertion point to the statement where the call was made. If there is no debug
information for the statement at the call location, SEGGER Embedded Studio opens a disassembly window at the
instruction.
158
Threads window
The Threads window displays the set of executing contexts on the target processor structured as a set of
queues.
The above example creates the named columns Name, Priority, State, and Time in the Threads window, with
the Time column sorted numerically rather than alphabetically.
If you don't supply the function init() in the threads script, the Threads window will create the default columns
Name, Priority, and State.
The methods Threads.clear(), Threads.newqueue(), and Threads.add() can be called from the function
update().
The Threads.clear() method clears the Threads window.
The Threads.newqueue() function takes a string argument and creates a new, top-level entry in the Threads
window. Subsequent entries added to this window will go under this entry. If you don't call this, new entries will
all be at the top level of the Threads window.
159
The Threads.add() function takes a variable number of string arguments, which should correspond to the
number of columns displayed by the Threads window. The last argument to the Threads.add() function
should be an array (possibly empty) containing the registers of the thread or, alternatively, a handle that can
be supplied a call to the threads script function getregs(handle), which will return an array when the thread is
selected in the Threads window. The array containing the registers should have elements in the same order in
which they are displayed in the CPU Registers displaytypically this will be in register-number order, e.g., r0, r1,
and so on.
function update()
{
Threads.clear();
Threads.newqueue("My Tasks");
Threads.add("Task1", "0", "Executing", "1000", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
Threads.add("Task2", "1", "Waiting", "2000", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
}
The above example will create a fixed output on the Threads window and is here to demonstrate how to call the
methods.
To get real thread state, you need to access the debugger from the threads script. To do this, you can use
the JavaScript method Debug.evaluate("expression"), which will evaluate the string argument as a debug
expression and return the result. The returned result will be an object if you evaluate an expression that denotes
a structure or an array. If the expression denotes a structure, each field can be accessed by using its field name.
So, if you have structs in the application as follows
struct task {
char *name;
unsigned char priority;
char *state;
unsigned time;
struct task *next;
unsigned registers[17];
unsigned thread_local_storage[4];
};
struct task task2 =
{
"Task2",
1,
"Waiting",
2000,
0,
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 },
{ 0,1,2,3 }
};
struct task task1 =
{
"Task1",
0,
"Executing",
1000,
&task2,
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 },
160
{ 0,1,2,3 }
};
You can use pointers and C-style cast to enable linked-list traversal.
var next = Debug.evaluate("&task1");
while (next)
{
var xt = Debug.evaluate("*(struct task*)"+next);
Threads.add(xt.name, xt.priority, xt.state, xt.time, xt.registers);
next = xt.next;
}
Note that, if the threads script goes into an endless loop, the debuggerand consequently SEGGER Embedded
Studiowill become unresponsive and you will need to kill SEGGER Embedded Studio using a task manager.
Therefore, the above loop is better coded as follows:
var next = Debug.evaluate("&task1");
var count = 0;
while (next && count < 10)
{
var xt = Debug.evaluate("*(struct task*)"+next);
Threads.add(xt.name, xt.priority, xt.state, xt.time, xt.registers);
next = xt.next;
count++;
}
You can speed up the Threads window update by not supplying the registers of the thread to the Threads.add()
function. To do this, you should supply a handle/pointer to the thread as the last argument to the Threads.add()
function. For example:
var next = Debug.evaluate("&task1");
var count = 0;
while (next && count < 10)
{
var xt = Debug.evaluate("*(struct task*)"+next);
Threads.add(xt.name, xt.priority, xt.state, xt.time, next);
next=xt.next;
count++;
}
When the thread is selected, the Threads window will call getregs(x) in the threads script. That function should
return the array of registers, for example:
function getregs(x)
{
return Debug.evaluate("((struct task*)"+x+")->registers");
}
161
If you use thread local storage, implementing the gettls(x) function enables you to return an expression for the
debugger to evaluate when the base address of the thread local storage is accessed, for example:
function gettls(x)
{
return "((struct task*)"+x+")->thread_local_storage";
}
The debugger may require the name of a thread which you can provide by implementing the getname(x)
function, for example:
function getname(x)
{
return Debug.evaluate("((struct task*)"+x+")->name");
}
162
163
164
165
166
Breakpoint expressions
The debugger can set breakpoints by evaluating simple C-like expressions. Note that the exact capabilities
offered by the hardware to assist in data breakpointing will vary from target to target; please refer to the
particular target interface you are using and the capabilities of your target silicon for exact details. The simplest
expression supported is a symbol name. If the symbol name is a function, a breakpoint occurs when the first
instruction of the symbol is about to be executed. If the symbol name is a variable, a breakpoint occurs when the
symbol has been accessed; this is termed a data breakpoint. For example, the expression x will breakpoint when
x is accessed. You can use a debug expression (see Debug expressions) as a breakpoint expression. For example,
x[4] will breakpoint when element 4 of array x is accessed, and @sp will breakpoint when the sp register is
accessed.
Data breakpoints can be specified, using the == operator, to occur when a symbol is accessed with a specific
value. The expression x == 4 will breakpoint when x is accessed and its value is 4. The operators <, >=, >;, >=,
==, and != can be used similarly. For example, @sp <= 0x1000 will breakpoint when register sp is accessed
and its value is less than or equal to 0x1000.
You can use the operator & to mask the value you wish to break on. For example, (x & 1) == 1 will
breakpoint when x is accessed and has an odd value.
You can use the operator && to combine comparisons. For example
(x >= 2) && (x <= 14)
will breakpoint when x is accessed and its value is between 2 and 14.
You can specify an arbitrary memory range using an array cast expression. For example, (char[256])
(0x1000) will breakpoint when the memory region 0x10000x10FF is accessed.
You can specify an inverse memory range using the ! operator. For example !(char[256])(0x1000) will
breakpoint when memory outside the range 0x10000x10FF is accessed.
167
Debug expressions
The debugger can evaluate simple expressions that can be displayed in the Watch window or as a tool-tip in the
code editor.
The simplest expression is an identifier the debugger tries to interpret in the following order:
an identifier that exists in the scope of the current context.
the name of a global identifier in the program of the current context.
Numbers can be used in expressions. Hexadecimal numbers must be prefixed with 0x.
Registers can be referenced by prefixing the register name with @.
The standard C and C++ operators !, ~, *, /, %, +, -, >>, <<, <, <=, >, >=, ==, |, &, ^, &&, and || are supported
on numeric types.
The standard assignment operators =, +=, -=, *=, /=, %=, >>, >>=, <<=, &=, |=, ^= are supported on numeric
types.
The array subscript operator [] is supported on array and pointer types.
The structure access operator . is supported on structured types (this also works on pointers to structures), and > works similarly.
The dereference operator (prefix *) is supported on pointers, the address-of (prefix &) and sizeof operators are
supported.
The addressof(filename, linenumber) operator will return the address of the specified source code line
number.
Function calling with parameters and return results.
Casting to basic pointer types is supported. For example, (unsigned char *)0x300 can be used to display the
memory at a given location.
Casting to basic array types is supported. For example, (unsigned char[256])0x100 can be used to reference a
memory region.
Operators have the precedence and associativity one expects of a C-like programming language.
168
Output window
The Output window contains logs and transcripts from various systems within SEGGER Embedded Studio. Most
notably, it contains the Transcript and Source Navigator Log.
Transcript
The Transcript contains the results of the last build or target operation. It is cleared on each build. Errors
detected by SEGGER Embedded Studio are shown in red and warnings are shown in yellow. Double-clicking
an error or warning in the build log will open the offending file at the error position. The commands used
for the build can be echoed to the build log by setting the Echo Build Command Lines environment
option. The transcript also shows a trace of the high-level loading and debug operations carried out on the
target. For downloading, uploading, and verification operations, it displays the time it took to carry out each
operation. The log is cleared for each new download or debug session.
Navigator Log
The Source Navigator Log displays a list of files the Source Navigator has parsed and the time it took to
parse each file.
169
Properties window
The Properties window displays properties of the current SEGGER Embedded Studio object. Using the
Properties window, you can set the build properties of your project, modify the editor defaults, and change
target settings.
170
Description
<BS>
Backspace
<CR>
Carriage return
<LF>
Linefeed
<ESC>[{attr1};...;{attrn}m
Set display attributes. The attributes 2-Dim, 5-Blink, 7Reverse, and 8-Hidden are not supported.
171
172
173
Downloads window
The Downloads Window displays a historical list of files downloaded over the Internet by SEGGER Embedded
Studio.
174
175
176
Description
Ignore Unity Build project properties and always build
individual project components.
The number of threads to launch when building
dependent project.
Build Options
Property
Automatically Build Before Debug
Environment/Build/Build Before
Debug Boolean
Build Macros
Environment/Macros/Global Macros StringList
Description
Enables auto-building of a project before downloading
if it is out of date.
Build macros that are shared across all solutions and
projects e.g. paths to library files.
Present a warning when you start to build that requires
the debugger to stop.
Selects whether build command lines are written to
the build log.
Selects whether the unprocessed error and warning
output from tools is displayed in the build log.
Moves the cursor to the first diagnostic after a build
completes with errors.
177
Compatibility Options
Property
Compiler Supports Section Renaming
ARM/Build/Compiler Can Rename
Sections Boolean
Description
Compiler supports the -mtext=t, -mdata=d, -mbss=b, mrodata=r section renaming options.
Installation Directory
Window Options
Property
Description
178
Description
Display Options
Property
Description
179
Source Path
Environment/Debugger/Source Path StringList
Description
ASCII
Environment/Debugger/Extended Tooltip
Display Mode/ASCII Boolean
Binary
Environment/Debugger/Extended Tooltip
Display Mode/Binary Boolean
Decimal
Environment/Debugger/Extended Tooltip
Display Mode/Decimal Boolean
Hexadecimal
Environment/Debugger/Extended Tooltip
Display Mode/Hexadecimal Boolean
Octal
Environment/Debugger/Extended Tooltip
Display Mode/Octal Boolean
Unsigned Decimal
Environment/Debugger/Extended Tooltip
Display Mode/Unsigned Decimal Boolean
Target Options
Property
Description
180
Window Options
Property
Clear Debug Terminal On Run
Environment/Clear Debug Terminal On
Run Boolean
Description
Clear the debug terminal automatically when a
program is run.
Hide the Output window when a load completes
without error.
Show the target log when a load starts.
181
Description
Text Size
Description
Description
Files To Search
Find History
Find In Files/Find History StringList
Folder History
Find In Files/Folder History StringList
Match Case
Find In Files/Match Case Boolean
Replace History
Find In Files/Replace History StringList
Search Dependencies
Find In Files/Search Dependencies Boolean
182
Search In
Find In Files/Context Enumeration
Internet Options
Property
Automatically Check For Packages
Environment/Internet/Check
Packages Boolean
Description
Specifies whether to enable downloading of the list of
available packages.
Specifies whether to enable checking for software
updates.
Specifies whether to enable downloading of the Latest
News RSS feeds.
Controls debugging traces of internet connections and
downloads.
The path to the external web browser to use when
accessing non-local files.
Specifies the IP address or hostname of the HTTP proxy
server. If empty, no HTTP proxy server will be used.
Description
Specifies whether to check package dependencies
when a solution is loaded.
183
Package Directory
Environment/Package/Destination
Directory String
Show Logos
Performance Options
Property
Description
Source Navigator/Indexing
Threads IntegerRange
Print Options
Property
Description
Bottom Margin
The page's bottom margin in millimetres.
Environment/Printing/Bottom
Margin IntegerRange
Left Margin
The page's left margin in millimetres.
Environment/Printing/Left
Margin IntegerRange
Page Orientation
The page's orientation.
Environment/Printing/
Orientation Enumeration
Page Size
Environment/Printing/Page Size Enumeration
Right Margin
Environment/Printing/Right
Margin IntegerRange
Top Margin
Environment/Printing/Top
Margin IntegerRange
Startup Options
Property
Description
184
Splash Screen
Environment/Splash Screen Enumeration
Description
Show or hide the status bar.
185
Description
Environment/Application Monospace
Font Font
Environment/Error Display
Timeout IntegerRange
Show Ribbon
Environment/General/Ribbon/Show Boolean
186
Description
Indent Context
Text Editor/Indent/Assembly Language/
Context Lines IntegerRange
Indent Mode
Text Editor/Indent/Assembly Language/
Indent Mode Enumeration
Indent Size
Text Editor/Indent/Assembly Language/
Size IntegerRange
Tab Size
Text Editor/Indent/Assembly Language/Tab
Size IntegerRange
Use Tabs
Text Editor/Indent/Assembly Language/Use
Tabs Boolean
User-Defined Keywords
Text Editor/Indent/Assembly Language/
Keywords StringList
Description
187
Indent Context
Text Editor/Indent/C and C++/Context
Lines IntegerRange
Indent Mode
Text Editor/Indent/C and C++/Indent
Mode Enumeration
Indent Size
Text Editor/Indent/C and C++/
Size IntegerRange
Tab Size
Text Editor/Indent/C and C++/Tab
Size IntegerRange
Use Tabs
Text Editor/Indent/C and C++/Use
Tabs Boolean
User-Defined Keywords
Text Editor/Indent/C and C++/
Keywords StringList
Default Settings
Property
Description
Indent Context
Text Editor/Indent/Default/Context
Lines IntegerRange
Indent Mode
Text Editor/Indent/Default/Indent
Mode Enumeration
188
Indent Size
Text Editor/Indent/Default/
Size IntegerRange
Tab Size
Text Editor/Indent/Default/Tab
Size IntegerRange
Use Tabs
Text Editor/Indent/Default/Use
Tabs Boolean
User-Defined Keywords
Text Editor/Indent/Default/
Keywords StringList
Java Settings
Property
Description
Indent Context
Text Editor/Indent/Java/Context
Lines IntegerRange
Indent Mode
Text Editor/Indent/Java/Indent
Mode Enumeration
Indent Size
Text Editor/Indent/Java/Size IntegerRange
Tab Size
Text Editor/Indent/Java/Tab
Size IntegerRange
Use Tabs
Text Editor/Indent/Java/Use Tabs Boolean
189
User-Defined Keywords
Text Editor/Indent/Java/Keywords StringList
190
Description
Preference Options
Property
Add Immediately
Description
Bypasses the confirmation dialog and immediately
Commit Immediately
Lock Immediately
Remove Immediately
Resolved Immediately
Revert Immediately
Unlock Immediately
Update Immediately
191
Description
The time in minutes between saving of auto recovery
backups files or 0 to disable generation of backup files.
The time in days to keep unrecovered backup files or 0
to disable deletion of unrecovered backup files.
Left Margin
Text Editor/Margins/Left IntegerRange
Right Margin
Text Editor/Margins/Right IntegerRange
Top Margin
Text Editor/Margins/Top IntegerRange
Description
The number of lines in the bottom margin.
Enable margins to fence and scroll around the cursor.
The number of characters in the left margin.
The number of characters in the right margin.
The number of lines in the right margin.
Editing Options
Property
Description
Column-mode Tab
Text Editor/Column Mode Tab Boolean
192
Description
Find History
Text Editor/Find/History StringList
Replace History
Text Editor/Replace/History StringList
Formatting Options
Property
Access Modifier Offset
Text Editor/Formatting/
AccessModifierOffset Integer
Description
The extra indent or outdent of access modifiers, e.g.
public:.
193
Align Operands
Text Editor/Formatting/
AlignOperands Boolean
Text Editor/Formatting/
types.
AlwaysBreakAfterDefinitionReturnType Boolean
Bin-Pack Arguments
Text Editor/Formatting/
BinPackArguments Boolean
194
Bin-Pack Parameters
Text Editor/Formatting/
BinPackParameters Boolean
Text Editor/Formatting/
BreakBeforeBinaryOperators Boolean
Text Editor/Formatting/
BreakBeforeBraces Enumeration
Text Editor/Formatting/
BreakBeforeTernaryOperators Boolean
Text Editor/Formatting/
commas and align the commas with the colon.
BreakConstructorInitializersBeforeComma Boolean
Text Editor/Formatting/
Cpp11BracedListStyle Boolean
Column Limit
Text Editor/Formatting/ColumnLimit Integer
Comment Pragmas
Text Editor/Formatting/
CommentPragmas String
Text Editor/Formatting/
line, put each initializer on its own line.
ConstructorInitializerAllOnOneLineOrOnePerLine Boolean
Text Editor/Formatting/
ConstructorInitializerIndentWidth Integer
Text Editor/Formatting/
ContinuationIndentWidth Integer
For-Each Macros
Text Editor/Formatting/
ForEachMacros StringList
Formatting Style
Text Editor/Formatting/
IndentCaseLabels Boolean
Indent Width
Text Editor/Formatting/IndentWidth Integer
195
Namespace Indentation
Text Editor/Formatting/
NamespaceIndentation Enumeration
Pointer Alignment
Text Editor/Formatting/
PointerAlignment Enumeration
196
Spaces In Angles
Text Editor/Formatting/
SpacesInAngles Boolean
Spaces In Parentheses
Text Editor/Formatting/
SpacesInParentheses Boolean
Standard
Text Editor/Formatting/
Standard Enumeration
Tab Style
Text Editor/Formatting/UseTab Enumeration
Tab Width
Text Editor/Formatting/
TabWidth IntegerRange
International
Property
Description
Mouse Options
Property
Description
197
Programmer Assistance
Property
ATTENTION Tag List
Text Editor/ATTENTION Tags StringList
Auto-Comment Text
Text Editor/Auto Comment Boolean
Description
Set the tags to display as ATTENTION comments.
Enable or disable automatically swapping
commenting on source lines by typing '/' with an
active selection.
198
Auto-Surround Text
Text Editor/Auto Surround Boolean
Check Spelling
Text Editor/Spell Checking Boolean
Save Options
Property
Description
Visual Appearance
Property
Description
199
Font
Text Editor/Antialias
Threshold IntegerRange
Line Numbers
200
Description
Controls whether the most recent call is at the top or
the bottom of the list.
Description
The maximum number of items held on the clipboard
ring before they are recycled.
Save the clipboard ring across SEGGER Embedded
Studio runs.
Description
201
Group Visibility
Windows/Outline/Group Visibility Boolean
Description
Macros (system and global) used to replace the start of
a filename on project file addition.
Show the project nodes colored for identification in
the Project Explorer.
Display a confirmation prompt before deleting a
configuration folder cotaining properties.
Display a confirmation prompt before forgetting
property modifications.
Controls where properties are displayed by the Project
External Editor
Environment/Project Explorer/External
Editor FileName
Favorite Properties
Environment/Project Explorer/Favorite
Properties StringList
202
Show Dependencies
Environment/Project Explorer/Dependencies Controls how the dependencies are displayed.
Display Enumeration
Show Properties
Environment/Project Explorer/Properties
Display Enumeration
Statistics Column
Environment/Project Explorer/Statistics
Display Boolean
203
Description
Properties Displayed
Environment/Properties Windows/Property
Display Format Enumeration
Target Options
Property
Description
Environment/Targets Window/Background
Target Scan Boolean
Description
Controls whether the variable address column is
displayed.
Description
204
Buffer Grouping
Environment/Windows/Grouping Enumeration
205
Command-line options
This section describes the command-line options accepted by SEGGER Embedded Studio.
Usage
emStudio [options] [files]
206
-D (Define macro)
Syntax
-D macro=value
Description
Define a SEGGER Embedded Studio macro value.
207
Description
Disable Clang support.
208
Description
Override the default value of the $(PackagesDir) macro.
209
Description
Allow multiple instances of SEGGER Embedded Studio to run at the same time. This behaviour can also be
enabled using the Environment > Startup Options > Allow Multiple SEGGER Embedded Studios environment
option.
210
Description
Set the SEGGER Embedded Studio root user data directory.
211
Description
Disable the saving of modified environment settings.
212
Description
Sets an environment setting to a specified value. For example:
-set-setting "Environment/Build/Show Command Lines=Yes"
213
Description
Sets the search path for finding project template files.
214
215
5. To begin the uninstall, click the Uninstall button at the top of the list.
216
217
218
Note that ARM exception handlers must be written in ARM assembly code. The CPU or board support package of
the project you have created will typically supply an ARM assembly-coded irq_handler implementation that will
enable you to write interrupt service routines as C functions.
219
_vectors This is the exception vector table. It is put into its own .vectors section in order to ensure that
it is always placed at address 0x00000000.
The vector table is structured as follows:
The first entry is the initial value of the stack pointer.
The second entry is the address of the reset handler function. The reset handler will usually carry out any
target-specific initialization and then jump to the _start entry point. In a C system, the _start entry point
is in the crt0.s file. During development it is usual to replace this jump with an endless loop which will
stop the device running potentially dangerous in-development code directly out of reset.
The following 15 entries are the addresses of the standard Cortex-M exception handlers ending with the
SysTick_ISR entry.
Subsequent entries are addresses of device-specific interrupt sources and their associated handlers.
For each exception handler, a weak symbol is declared that will implement an endless loop. You can
implement your own exception handler as a regular C function. Note that the name of the C function
must match the name in the startup code e.g. void SysTick_ISR(void). You can use the C preprocessor to
rename the symbol in the startup code if you have existing code with different exception handler names e.g.
SysTick_ISR=SysTick_Handler.
220
Startup code
The following section describes the role of the C runtime-startup code, crt0.s (and the Cortex-M3/Thumb-2
equivalent thumb_crt0.s).
When you create a new project to produce an executable file using a target-specific project template, the crt0.s
file is added to the project. Initially, a shared version of this file is added to the project. If you want to modify this
file, right-click it in the Project Explorer and then select Import from the shortcut menu to copy the file to your
project directory.
The entry point of the C runtime-startup code is _start. In a typical system, this will be called by the targetspecific startup code after it has initialized the target.
The C runtime carries out the following actions:
Initialize the stacks.
If required, copy the contents of the .data (initialized data) section from non-volatile memory.
If required, copy the contents of the .fast section from non-volatile memory to SRAM.
Initialize the .bss section to zero.
Initialize the heap.
Call constructors.
If compiled with FULL_LIBRARY, get the command line from the host using debug_getargs and set
registers to supply argc and argv to main.
Call the main entry point.
On return from main or when exit is called
If compiled with FULL_LIBRARY, call destructors.
If compiled with FULL_LIBRARY, call atexit functions.
If compiled with FULL_LIBRARY, call debug_exit while supplying the return result from main.
Wait in exit loop.
Program sections
The following program sections are used for the C runtime in section-placement files:
Section name
Description
.vectors
.init
.ctors
.dtors
.text
.fast
221
.data
.bss
.rodata
.ARM.exidx
Stacks
The ARM maintains six separate stacks. The position and size of these stacks are specified in the project's sectionplacement or memory-map file by the following program sections:
Section name
Description
.stack
__STACKSIZE__
.stack_svc
__STACKSIZE_SVC__
.stack_irq
__STACKSIZE_IRQ__
.stack_fiq
__STACKSIZE_FIQ__
.stack_abt
__STACKSIZE_ABT__
.stack_und
__STACKSIZE_UND__
For Cortex-M devices the following stacks and linker symbol stack sizes are defined:
Section name
Description
.stack
__STACKSIZE__
Main stack.
.stack_process
__STACKSIZE_PROCESS__
Process stack.
The crt0.s startup code references these sections and initializes each of the stack-pointer registers to point to the
appropriate location. To change the location in memory of a particular stack, the section should be moved to the
required position in the section-placement or memory-map file.
Should your application not require one or more of these stacks, you can remove those sections from the
memory-map file or set the size to 0 and remove the initialization code from the crt0.s file.
222
address, the crt0.s startup code will copy the .fast section from the load address to the run address before
calling the main entry point.
The heap
The position and size of the heap is specified in the project's section-placement or memory-map file by the
.heap program section.
The startup code in crt0.s references this section and initializes the heap. To change the position of the heap,
the section should be moved to the required position in the section-placement or memory-map file.
There is a Heap Size linker project property you can modify in order to alter the heap size. For compatibility with
earlier versions of SEGGER Embedded Studio, you can also specify the heap size using the heap section's Size
property in the section-placement or memory-map file.
Should your application not require the heap functions, you can remove the heap section from the memorymap file or set the size to zero and remove the heap-initialization code from the crt0.s file.
223
Section Placement
SEGGER Embedded Studio's memory-map files are XML files and are used
Linking: by the linker, to describe how to lay out a program in memory.
Loading: by the loader, to check whether a program being downloaded will actually fit into the target's
memory.
Debugging: by the debugger, to describe the location and types of memory a target has. This
information is used to decide how to debug the programfor example, whether to set hardware or
software breakpoints on particular memory location.
Section placement files map program sections used in your program into the memory spaces defined in the
memory map. For instance, it's common for code and read-only data to be programmed into non-volatile flash
memory, whereas read-write data needs to be mapped onto either internal or external RAM.
Memory map files are provided in the CPU support package you are using and are referenced in executable
projects by the Memory Map File project property. Section-placement files are provided in the base SEGGER
Embedded Studio distribution.
Description
flash_placement.xml
flash_run_text_from_ram_placement.xml
internal_sram_placement.xml
flash_placement.xml
internal_sram_placement.xml
Description
flash_placement.xml
flash_placement2.xml
224
flash_to_ram_placement.xml
ram_placement.xml
The memory segments defined in the section placement files have macro-expandable names which can be
defined using the Section Placement Macros project property.
Some of the section placement files have a macro-expandable start attribute in the first program section. You
can use this to reserve space at the beginning of the memory segment.
225
226
227
Floating point
The SEGGER Embedded Studio C library uses IEEE floating point format as specified by the ISO 60559 standard
with restrictions.
This library favors code size and execution speed above absolute precision. It is suitable for applications
that need to run quickly and not consume precious resources in limited environments. The library does not
implement features rarely used by simple applications: floating point exceptions, rounding modes, and
subnormals.
NaNs and infinities are supported and correctly generated. The only rounding mode supported is round-tonearest. Subnormals are always flushed to a correctly-signed zero. The mathematical functions use stable
approximations and do their best to cater ill-conditioned inputs.
228
This looks simple enough. We're using the sinf function which computes the sine of a float and returns a float
result. There appears to be no mention of a double anywhere, yet the compiler generates code that calls double
support routinesbut why?
The answer is that the constant 2.0 is a double constant, not a float constant. That is enough to force the
compiler to convert both operands of the multiplication to double format, perform the multiplication in double
precision, and then convert the result back to float precision. To avoid this surprise, the code should have been
written:
// Compute sin(2x)
float sin_two_x(float x)
{
return sinf(2.0F * x);
}
This uses a single precision floating-point constant 2.0F. It's all too easy to forget to correctly type your floatingpoint constants, so if you compile your program with double meaning the same as float, you can forget all
about adding the 'F' suffix to your floating point constants.
As an aside, the C99 standard is very strict about the way that floating-point is implemented and the latitude the
compiler has to rearrange and manipulate expressions that have floating-point operands. The compiler cannot
second-guess user intention and use a number of useful mathematical identities and algebraic simplifications
because in the world of IEC 60559 arithmetic many algebraic identities, such as x * 1 = x, do not hold when x
takes one of the special values NaN, infinity, or negative zero.
229
Again, no mention of a double anywhere, but double support routines are now required. The reason is that ISO
C requires that float arguments are promoted to double when they are passed to the non-fixed part of variadic
functions such as printf. So, even though your application may never mention double, double arithmetic may
be required simply because you use printf or one of its near relatives.
If, however, you compile your code with 32-bit doubles, then there is no requirement to promote a float to a
double as they share the same internal format.
230
Multithreading
The SEGGER Embedded Studio libraries support multithreading, for example, where you are using CTL or a thirdparty real-time operating system (RTOS).
Where you have single-threaded processes, there is a single flow of control. However, in multithreaded
applications there may be several flows of control which access the same functions, or the same resources,
concurrently. To protect the integrity of resources, any code you write for multithreaded applications must be
reentrant and thread-safe.
Reentrancy and thread safety are both related to the way functions in a multithreaded application handle
resources.
Reentrant functions
A reentrant function does not hold static data over successive calls and does not return a pointer to static data.
For this type of function, the caller provides all the data that the function requires, such as pointers to any
workspace. This means that multiple concurrent calls to the function do not interfere with each other, that the
function can be called in mainline code, and that the function can be called from an interrupt service routine.
Thread-safe functions
A thread-safe function protects shared resources from concurrent access using locks. In C, local variables are
held in processor registers or are on the stack. Any function that does not use static data, or other shared
resources, is thread-safe. In general, thread-safe functions are safe to call from any thread but cannot be called
directly, or indirectly, from an interrupt service routine.
231
232
233
234
Customizing putchar
To use the standard output functions putchar, puts, and printf, you need to customize the way that characters
are written to the standard output device. These output functions rely on a function __putchar that outputs a
character and returns an indication of whether it was successfully written.
The prototype for __putchar is
int __putchar(int ch);
This hands off output of the character ch to the low-level debug output routine, debug_putchar.
Whilst this is an adequate implementation of __putchar, it does consume stack space for an unnecessary nested
call and associated register saving. A better way of achieving the same result is to define the low-level symbol for
__putchar to be equivalent to the low-level symbol for debug_putchar. To do this, we need to instruct the linker
to make the symbols equivalent.
Select the project node in the Project Explorer.
Display the Properties Window.
Enter the text __putchar=debug_putchar into the Linker > Linker Symbol Definitions property of
the Linker Options group.
235
The standard functions that perform input and output are the printf and scanf functions.These functions
convert between internal binary and external printable data. In some cases, though, you need to read and write
formatted data on other channels, such as other RS232 ports. This section shows how you can extend the I/O
library to best implement these function.
These functions return a positive value if there is no error outputting the character and EOF if there was an
error. The second parameter, ctx, is the context that the high-level formatting routines use to implement the C
standard library functions.
Using a classic implementation, you would use sprintf to format the string for output and then output it:
void uart0_printf(const char *fmt, ...)
{
char buf[80], *p;
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
for (p = buf; *p; ++p)
uart0_putc(*p, 0); // null context
va_end(ap);
}
We would, of course, need an identical routine for outputting to the other UART. This code is portable, but it
requires an intermediate buffer of 80 characters. On small systems, this is quite an overhead, so we could reduce
the buffer size to compensate. Of course, the trouble with that means that the maximum number of characters
that can be output by a single call to uart0_printf is also reduced. What would be good is a way to output
characters to one of the UARTs without requiring an intermediate buffer.
236
} __printf_t;
This type is used by the library functions to direct what the formatting routines do with each character they need
to output. If string is non-zero, the character is appended is appended to the string pointed to by string; if
output_fn is non-zero, the character is output through the function output_fn with the context passed as the
second parameter.
The member charcount counts the number of characters currently output, and maxchars defines the maximum
number of characters output by the formatting routine __vfprintf.
We can use this type and function to rewrite uart0_printf:
int uart0_printf(const char *fmt, ...)
{
int n;
va_list ap;
__printf_t iod;
va_start(ap, fmt);
iod.string = 0;
iod.maxchars = INT_MAX;
iod.output_fn = uart0_putc;
n = __vfprintf(\&iod, fmt, ap);
va_end(ap);
return n;
}
This function has no intermediate buffer: when a character is ready to be output by the formatting routine, it
calls the output_fn function in the descriptor iod to output it immediately. The maximum number of characters
isn't limited as the maxchars member is set to INT_MAX. if you wanted to limit the number of characters output
you can simply set the maxchars member to the appropriate value before calling __vfprintf.
We can adapt this function to take a UART number as a parameter:
int uart_printf(int uart, const char *fmt, ...)
{
int n;
va_list ap;
__printf_t iod;
va_start(ap, fmt);
iod.is_string = 0;
iod.maxchars = INT_MAX;
iod.output_fn = uart ? uart1_putc : uart0_putc;
n = __vfprintf(\&iod, fmt, ap);
va_end(ap);
return n;
}
__vfprintf returns the actual number of characters printed, which you may wish to dispense with and make the
uart_printf routine return void.
237
The function getc_fn reads a single character from the UART, and ungetc_fn pushes back a character to the
UART. You can push at most one character back onto the stream.
Here's an implementation of functions to read and write from a single UART:
static int uart0_ungot = EOF;
int uart0_getc(void)
{
if (uart0_ungot)
{
int c = uart0_ungot;
uart0_ungot = EOF;
return c;
}
else
return read_char_from_uart(0);
}
int uart0_ungetc{int c)
{
uart0_ungot = c;
}
You can use these two functions to perform formatted input using the UART:
int uart0_scanf(const char *fmt, ...)
{
__stream_scanf_t iod;
va_list a;
int n;
va_start(a, fmt);
iod.is_string = 0;
iod.getc_fn = uart0_getc;
iod.ungetc_fn = uart0_ungetc;
n = __vfscanf((__scanf_t *)\&iod, (const unsigned char *)fmt, a);
va_end(a);
return n;
}
Using this template, we can add functions to do additional formatted input from other UARTs or devices, just as
we did for formatted output.
238
Locales
The SEGGER Embedded Studio C library supports wide characters, multi-byte characters and locales. However,
as not all programs require full localization, you can tailor the exact support provided by the SEGGER Embedded
Studio C library to suit your application. These sections describe how to add new locales to your application and
customize the runtime footprint of the C library.
239
240
Multi-byte characters
SEGGER Embedded Studio supports multi-byte encoding and decoding of characters. Most new software on the
desktop uses Unicode internally and UTF-8 as the external, on-disk encoding for files and for transport over 8-bit
mediums such as network connections.
However, in embedded software there is still a case to use code pages, such as ISO-Latin1, to reduce the
footprint of an application whilst also providing extra characters that do not form part of the ASCII character set.
The SEGGER Embedded Studio C library can support both models and you can choose a combination of models,
dependent upon locale, or construct a custom locale.
241
242
243
Installing a locale
If the locale you request using setlocale is neither C nor POSIX, the C library calls the function
__user_find_locale to find a user-supplied locale. The standard implementation of this function is to return a
null pointer which indicates that no additional locales are installed and, hence, no locale matches the request.
The prototype for __user_find_locale is:
const __RAL_locale_t *__user_find_locale(const char *locale);
The parameter locale is the locale to find; the locale name is terminated either by a zero character or by a
semicolon. The locale name, up to the semicolon or zero, is identical to the name passed to setlocale when you
select a locale.
Now let's install the Hungarian locale using both UTF-8 and ISO 8859-2 encodings. The UTF-8 codecs are
included in the SEGGER Embedded Studio C library, but the Hungarian locale and the ISO 8859-2 codec are not.
You will find the file locale_hu_HU.c in the source directory as described in the previous section. Add this file to
your project.
Although this adds the data needed for the locale, it does not make the locale available for the C library: we need
to write some code for __user_find_locale to return the appropriate locales.
To create the locales, we need to add the following code and data to tie everything together:
#include <__crossworks.h>
static const __RAL_locale_t hu_HU_utf8 = {
"hu_HU.utf8",
&locale_hu_HU,
&codeset_utf8
};
static const __RAL_locale_t hu_HU_iso_8859_2 = {
"hu_HU.iso_8859_2",
&locale_hu_HU,
&codeset_iso_8859_2
};
const __RAL_locale_t *
__user_find_locale(const char *locale)
{
if (__RAL_compare_locale_name(locale, hu_HU_utf8.name) == 0)
return &hu_HU_utf8;
else if (__RAL_compare_locale_name(locale, hu_HU_iso_8859_2.name) == 0)
return &hu_HU_iso_8859_2;
else
return 0;
}
244
In addition to this, you must provide a buffer, __user_locale_name_buffer, for locale names encoded
by setlocale. The buffer must be large enough to contain five locale names, one for each category. In the
above example, the longest locale name is hu_HU.iso_8859_2 which is 16 characters in length. Using this
information, buffer must be at least (16+1)5 = 85 characters in size:
const char __user_locale_name_buffer[85];
245
You can install this directly into the locale without using setlocale:
__RAL_global_locale.__category[LC_COLLATE]
__RAL_global_locale.__category[LC_CTYPE]
__RAL_global_locale.__category[LC_MONETARY]
__RAL_global_locale.__category[LC_NUMERIC]
__RAL_global_locale.__category[LC_TIME]
=
=
=
=
=
&cz_locale;
&cz_locale;
&cz_locale;
&cz_locale;
&cz_locale;
246
Description
<assert.h>
<debugio.h>
Describes the virtual console services and semihosting support that SEGGER Embedded Studio
provides to help you when developing your
applications.
<ctype.h>
<errno.h>
<float.h>
<limits.h>
<locale.h>
<math.h>
<setjmp.h>
<stdarg.h>
<stddef.h>
<stdio.h>
<stdlib.h>
<string.h>
<time.h>
<wchar.h>
247
<assert.h>
API Summary
Macros
assert
Functions
__assert
248
__assert
Synopsis
void __assert(const char *expression,
const char *filename,
int line);
Description
There is no default implementation of __assert. Keeping __assert out of the library means that you can can
customize its behaviour without rebuilding the library. You must implement this function where expression
is the stringized expression, filename is the filename of the source file and line is the linenumber of the failed
assertion.
249
assert
Synopsis
#define assert(e) ...
Description
If NDEBUG is defined as a macro name at the point in the source file where <assert.h> is included, the assert
macro is defined as:
#define assert(ignore) ((void)0)
If NDEBUG is not defined as a macro name at the point in the source file where <assert.h> is included, the assert
macro expands to a void expression that calls __assert.
#define assert(e) ((e) ? (void)0 : __assert(#e, __FILE__, __LINE__))
When such an assert is executed and e is false, assert calls the __assert function with information about the
particular call that failed: the text of the argument, the name of the source file, and the source line number.
These are the stringized expression and the values of the preprocessing macros __FILE__ and __LINE__.
Note
The assert macro is redefined according to the current state of NDEBUG each time that <assert.h> is included.
250
<complex.h>
API Summary
Trigonometric functions
cacos
cacosf
casin
casinf
catan
catanf
ccos
ccosf
csin
csinf
ctan
ctanf
cacoshf
casinh
casinhf
catanh
catanhf
ccosh
ccoshf
csinh
csinhf
ctanh
ctanhf
cexpf
clog
251
clogf
cabsf
cpow
cpowf
csqrt
csqrtf
Manipulation functions
carg
cargf
cimag
cimagf
conj
conjf
cproj
cprojf
creal
crealf
252
cabs
Synopsis
double cabs(double complex z);
Description
cabs returns the absolute value of z.
253
cabsf
Synopsis
float cabsf(float complex z);
Description
cabsf returns the absolute value of z.
254
cacos
Synopsis
double complex cacos(double complex z);
Description
cacos returns the principal value the inverse cosine of z with branch cuts outside the interval [-1,+1] on the
real axis. The principal value lies in the interval [0, ] on the real axis and in the range of a strip mathematically
unbounded on the imaginary axis.
255
cacosf
Synopsis
float complex cacosf(float complex z);
Description
cacosf returns the principal value the inverse cosine of z with branch cuts outside the interval [-1,+1] on the
real axis. The principal value lies in the interval [0, ] on the real axis and in the range of a strip mathematically
unbounded on the imaginary axis.
256
cacosh
Synopsis
double complex cacosh(double complex z);
Description
cacosh returns the principal value the inverse hyperbolic cosine of z with branch cuts of values less than 1 on
the real axis. The principal value lies in the range of a half-strip of non-negative values on the real axis and in the
interval [-i,+i] on the imaginary axis.
257
cacoshf
Synopsis
float complex cacoshf(float complex _z);
Description
cacoshf returns the principal value the inverse hyperbolic cosine of z with branch cuts of values less than 1 on
the real axis. The principal value lies in the range of a half-strip of non-negative values on the real axis and in the
interval [-i,+i] on the imaginary axis.
258
carg
Synopsis
double carg(double complex z);
Description
carg computes the argument of z with a branch cut along the negative real axis.
259
cargf
Synopsis
float cargf(float complex z);
Description
cargf computes the argument of z with a branch cut along the negative real axis.
260
casin
Synopsis
double complex casin(double complex z);
Description
casin returns the principal value the inverse sine of z with branch cuts outside the interval [-1,+1] on the real
axis. The principal value lies in the interval [, ] on the real axis and in the range of a strip mathematically
unbounded on the imaginary axis.
261
casinf
Synopsis
float complex casinf(float complex z);
Description
casinf returns the principal value the inverse sine of z with branch cuts outside the interval [-1,+1] on the real
axis. The principal value lies in the interval [, ] on the real axis and in the range of a strip mathematically
unbounded on the imaginary axis.
262
casinh
Synopsis
double complex casinh(double complex z);
Description
casinh returns the principal value the inverse hyperbolic sine of z with branch cuts outside the inteval [-i,+i] on
the imaginary axis. The principal value lies in the range of a strip mathematically unbounded on the real axis and
in the interval [-i,+i] on the imaginary axis.
263
casinhf
Synopsis
float complex casinhf(float complex z);
Description
casinhf returns the principal value the inverse hyperbolic sine of z with branch cuts outside the inteval [-i,+i] on
the imaginary axis. The principal value lies in the range of a strip mathematically unbounded on the real axis and
in the interval [-i,+i] on the imaginary axis.
264
catan
Synopsis
double complex catan(double complex z);
Description
catan returns the principal value the inverse sine of z with branch cuts outside the interval [-1,+1] on the real
axis. The principal value lies in the interval [, ] on the real axis and in the range of a strip mathematically
unbounded on the imaginary axis.
265
catanf
Synopsis
float complex catanf(float complex z);
Description
catanf returns the principal value the inverse sine of z with branch cuts outside the interval [-1,+1] on the real
axis. The principal value lies in the interval [, ] on the real axis and in the range of a strip mathematically
unbounded on the imaginary axis.
266
catanh
Synopsis
double complex catanh(double complex z);
Description
catanh returns the principal value the inverse hyperbolic sine of z with branch cuts outside the inteval [-1,+1] on
the real axis. The principal value lies in the range of a strip mathematically unbounded on the real axis and in the
interval [-i,+i] on the imaginary axis.
267
catanhf
Synopsis
float complex catanhf(float complex z);
Description
catanhf returns the principal value the inverse hyperbolic sine of z with branch cuts outside the inteval [-1,+1]
on the real axis. The principal value lies in the range of a strip mathematically unbounded on the real axis and in
the interval [-i,+i] on the imaginary axis.
268
ccos
Synopsis
double complex ccos(double complex z);
Description
ccos returns the complex cosine of z.
269
ccosf
Synopsis
float complex ccosf(float complex z);
Description
ccosf returns the complex cosine of z.
270
ccosh
Synopsis
double complex ccosh(double complex z);
Description
ccosh returns the complex hyperbolic cosine of z.
271
ccoshf
Synopsis
float complex ccoshf(float complex z);
Description
ccoshf returns the complex hyperbolic cosine of z.
272
cexp
Synopsis
double complex cexp(double complex z);
Description
cexp returns the complex base-e exponential value of z.
273
cexpf
Synopsis
float complex cexpf(float complex z);
Description
cexpf returns the complex base-e exponential value of z.
274
cimag
Synopsis
double cimag(double complex);
Description
cimag computes the imaginary part of z.
275
cimagf
Synopsis
float cimagf(float complex);
Description
cimagf computes the imaginary part of z.
276
clog
Synopsis
double complex clog(double complex z);
Description
clog returns the complex base-e logarithm value of z.
277
clogf
Synopsis
float complex clogf(float complex z);
Description
clogf returns the complex base-e logarithm value of z.
278
conj
Synopsis
double complex conj(double complex);
Description
conj computes the conjugate of z by reversing the sign of the imaginary part.
279
conjf
Synopsis
float complex conjf(float complex);
Description
conjf computes the conjugate of z by reversing the sign of the imaginary part.
280
cpow
Synopsis
double complex cpow(double complex x,
double complex y);
Description
cpow computes x raised to the power y with a branch cut for the x along the negative real axis.
281
cpowf
Synopsis
float complex cpowf(float complex x,
float complex y);
Description
cpowf computes x raised to the power y with a branch cut for the x along the negative real axis.
282
cproj
Synopsis
double complex cproj(double complex);
Description
cproj computes the projection of z on the Riemann sphere.
283
cprojf
Synopsis
float complex cprojf(float complex);
Description
cprojf computes the projection of z on the Riemann sphere.
284
creal
Synopsis
double creal(double complex);
Description
creal computes the real part of z.
285
crealf
Synopsis
float crealf(float complex);
Description
crealf computes the real part of z.
286
csin
Synopsis
double complex csin(double complex z);
Description
csin returns the complex sine of z.
287
csinf
Synopsis
float complex csinf(float complex z);
Description
csinf returns the complex sine of z.
288
csinh
Synopsis
double complex csinh(double complex z);
Description
csinh returns the complex hyperbolic sine of z.
289
csinhf
Synopsis
float complex csinhf(float complex z);
Description
csinhf returns the complex hyperbolic sine of z.
290
csqrt
Synopsis
double complex csqrt(double complex z);
Description
csqrt computes the complex square root of z with a branch cut along the negative real axis.
291
csqrtf
Synopsis
float complex csqrtf(float complex z);
Description
csqrtf computes the complex square root of z with a branch cut along the negative real axis.
292
ctan
Synopsis
double complex ctan(double complex z);
Description
ctan returns the complex tangent of z.
293
ctanf
Synopsis
float complex ctanf(float complex z);
Description
ctanf returns the complex tangent of z.
294
ctanh
Synopsis
double complex ctanh(double complex z);
Description
ctanh returns the complex hyperbolic tangent of z.
295
ctanhf
Synopsis
float complex ctanhf(float complex z);
Description
ctanhf returns the complex hyperbolic tangent of z.
296
<ctype.h>
API Summary
Classification functions
isalnum
Is character alphanumeric?
isalpha
Is character alphabetic?
isblank
iscntrl
Is character a control?
isdigit
isgraph
islower
isprint
Is character printable?
ispunct
isspace
isupper
isxdigit
Conversion functions
tolower
toupper
Is character alphanumeric?
isalpha_l
Is character alphabetic?
isblank_l
iscntrl_l
isdigit_l
isgraph_l
islower_l
isprint_l
Is character printable?
ispunct_l
isspace_l
isupper_l
isxdigit_l
297
toupper_l
298
isalnum
Synopsis
int isalnum(int c);
Description
isalnum returns nonzero (true) if and only if the value of the argument c is an alphabetic or numeric character.
299
isalnum_l
Synopsis
int isalnum_l(int c,
locale_t loc);
Description
isalnum_l returns nonzero (true) if and only if the value of the argument c is a alphabetic or numeric character in
locale loc.
300
isalpha
Synopsis
int isalpha(int c);
Description
isalpha returns true if the character c is alphabetic. That is, any character for which isupper or islower returns
true is considered alphabetic in addition to any of the locale-specific set of alphabetic characters for which none
of iscntrl, isdigit, ispunct, or isspace is true.
In the C locale, isalpha returns nonzero (true) if and only if isupper or islower return true for value of the
argument c.
301
isalpha_l
Synopsis
int isalpha_l(int c,
locale_t loc);
Description
isalpha_l returns nonzero (true) if and only if isupper or islower return true for value of the argument c in locale
loc.
302
isblank
Synopsis
int isblank(int c);
Description
isblank returns nonzero (true) if and only if the value of the argument c is either a space character (' ') or the
horizontal tab character ('\\t').
303
isblank_l
Synopsis
int isblank_l(int c,
locale_t loc);
Description
isblank_l returns nonzero (true) if and only if the value of the argument c is either a space character (' ') or the
horizontal tab character ('\\t') in locale loc.
304
iscntrl
Synopsis
int iscntrl(int c);
Description
iscntrl returns nonzero (true) if and only if the value of the argument c is a control character. Control characters
have values 0 through 31 and the single value 127.
305
iscntrl_l
Synopsis
int iscntrl_l(int c,
locale_t loc);
Description
iscntrl_l returns nonzero (true) if and only if the value of the argument c is a control character in locale loc.
306
isdigit
Synopsis
int isdigit(int c);
Description
isdigit returns nonzero (true) if and only if the value of the argument c is a digit.
307
isdigit_l
Synopsis
int isdigit_l(int c,
locale_t loc);
Description
isdigit_l returns nonzero (true) if and only if the value of the argument c is a decimal digit in locale loc.
308
isgraph
Synopsis
int isgraph(int c);
Description
isgraph returns nonzero (true) if and only if the value of the argument c is any printing character except space ('
').
309
isgraph_l
Synopsis
int isgraph_l(int c,
locale_t loc);
Description
isgraph_l returns nonzero (true) if and only if the value of the argument c is any printing character except space
(' ') in locale loc.
310
islower
Synopsis
int islower(int c);
Description
islower returns nonzero (true) if and only if the value of the argument c is an lowercase letter.
311
islower_l
Synopsis
int islower_l(int c,
locale_t loc);
Description
islower_l returns nonzero (true) if and only if the value of the argument c is an lowercase letter in locale loc.
312
isprint
Synopsis
int isprint(int c);
Description
isprint returns nonzero (true) if and only if the value of the argument c is any printing character including space
(' ').
313
isprint_l
Synopsis
int isprint_l(int c,
locale_t loc);
Description
isprint_l returns nonzero (true) if and only if the value of the argument c is any printing character including
space (' ') in locale loc.
314
ispunct
Synopsis
int ispunct(int c);
Description
ispunct returns nonzero (true) for every printing character for which neither isspace nor isalnum is true.
315
ispunct_l
Synopsis
int ispunct_l(int c,
locale_t loc);
Description
ispunct_l returns nonzero (true) for every printing character for which neither isspace nor isalnum is true in in
locale loc.
316
isspace
Synopsis
int isspace(int c);
Description
isspace returns nonzero (true) if and only if the value of the argument c is a standard white-space character.
The standard white-space characters are space (' '), form feed ('\\f'), new-line ('\\n'), carriage return ('\
\r'), horizontal tab ('\\t'), and vertical tab ('\v').
317
isspace_l
Synopsis
int isspace_l(int c,
locale_t loc);
Description
isspace_l returns nonzero (true) if and only if the value of the argument c is a standard white-space character in
in locale loc..
318
isupper
Synopsis
int isupper(int c);
Description
isupper returns nonzero (true) if and only if the value of the argument c is an uppercase letter.
319
isupper_l
Synopsis
int isupper_l(int c,
locale_t loc);
Description
isupper_l returns nonzero (true) if and only if the value of the argument c is an uppercase letter in locale loc.
320
isxdigit
Synopsis
int isxdigit(int c);
Description
isxdigit returns nonzero (true) if and only if the value of the argument c is a hexadecimal digit.
321
isxdigit_l
Synopsis
int isxdigit_l(int c,
locale_t loc);
Description
isxdigit_l returns nonzero (true) if and only if the value of the argument c is a hexadecimal digit in locale loc.
322
tolower
Synopsis
int tolower(int c);
Description
tolower converts an uppercase letter to a corresponding lowercase letter. If the argument c is a character for
which isupper is true and there are one or more corresponding characters, as specified by the current locale, for
which islower is true, the tolower function returns one of the corresponding characters (always the same one for
any given locale); otherwise, the argument is returned unchanged.
Note that even though isupper can return true for some characters, tolower may return that uppercase
character unchanged as there are no corresponding lowercase characters in the locale.
323
tolower_l
Synopsis
int tolower_l(int c,
locale_t loc);
Description
tolower_l converts an uppercase letter to a corresponding lowercase letter in locale loc. If the argument c is a
character for which isupper is true in locale loc, tolower_l returns the corresponding lowercase letter; otherwise,
the argument is returned unchanged.
324
toupper
Synopsis
int toupper(int c);
Description
toupper converts a lowercase letter to a corresponding uppercase letter. If the argument is a character for
which islower is true and there are one or more corresponding characters, as specified by the current locale, for
which isupper is true, toupper returns one of the corresponding characters (always the same one for any given
locale); otherwise, the argument is returned unchanged. Note that even though islower can return true for some
characters, toupper may return that lowercase character unchanged as there are no corresponding uppercase
characters in the locale.
325
toupper_l
Synopsis
int toupper_l(int c,
locale_t loc);
Description
toupper_l converts a lowercase letter to a corresponding uppercase letter in locale loc. If the argument c
is a character for which islower is true in locale loc, toupper_l returns the corresponding uppercase letter;
otherwise, the argument is returned unchanged.
326
<debugio.h>
API Summary
File Functions
debug_clearerr
debug_fclose
debug_feof
debug_ferror
debug_fflush
debug_fgetc
debug_fgetpos
debug_fgets
Read a string
debug_filesize
debug_fopen
debug_fprintf
Formatted write
debug_fprintf_c
Formatted write
debug_fputc
Write a character
debug_fputs
Write a string
debug_fread
Read data
debug_freopen
debug_fscanf
Formatted read
debug_fscanf_c
Formatted read
debug_fseek
debug_fsetpos
debug_ftell
debug_fwrite
Write data
debug_remove
debug_rename
debug_rewind
debug_tmpfile
debug_tmpnam
debug_ungetc
Push a character
debug_vfprintf
Formatted write
debug_vfscanf
Formatted read
327
Formatted write
debug_printf_c
Formatted write
debug_putchar
Write a character
debug_puts
Write a string
debug_vprintf
Formatted write
debug_getchar
debug_getd
debug_getf
debug_geti
debug_getl
debug_getll
debug_gets
String read
debug_getu
debug_getul
debug_getull
debug_kbhit
debug_scanf
Formatted read
debug_scanf_c
Formatted read
debug_vscanf
Formatted read
Debugger Functions
debug_abort
Stop debugging
debug_break
Stop target
debug_enabled
debug_exit
Stop debugging
debug_getargs
Get arguments
debug_loadsymbols
debug_runtime_error
debug_unloadsymbols
Misc Functions
debug_getenv
debug_perror
Display error
debug_system
Execute command
328
debug_time
get time
329
debug_abort
Synopsis
void debug_abort(void);
Description
debug_abort causes the debugger to exit and a failure result is returned to the user.
330
debug_break
Synopsis
void debug_break(void);
Description
debug_break causes the debugger to stop the target and position the cursor at the line that called
debug_break.
331
debug_clearerr
Synopsis
void debug_clearerr(DEBUG_FILE *stream);
Description
debug_clearerr clears any error indicator or end of file condition for the stream.
332
debug_enabled
Synopsis
int debug_enabled(void);
Description
debug_enabled returns non-zero if the debugger is connected - you can use this to test if a debug input/output
functions will work.
333
debug_exit
Synopsis
void debug_exit(int result);
Description
debug_exit causes the debugger to exit and result is returned to the user.
334
debug_fclose
Synopsis
int debug_fclose(DEBUG_FILE *stream);
Description
debug_fclose flushes any buffered output of the stream and then closes the stream.
debug_fclose returns 0 on success or -1 if there was an error.
335
debug_feof
Synopsis
int debug_feof(DEBUG_FILE *stream);
Description
debug_feof returns non-zero if the end of file condition is set for the stream.
336
debug_ferror
Synopsis
int debug_ferror(DEBUG_FILE *stream);
Description
debug_ferror returns non-zero if the error indicator is set for the stream.
337
debug_fflush
Synopsis
int debug_fflush(DEBUG_FILE *stream);
Description
debug_fflush flushes any buffered output of the stream.
debug_fflush returns 0 on success or -1 if there was an error.
338
debug_fgetc
Synopsis
int debug_fgetc(DEBUG_FILE *stream);
Description
debug_fgetc reads and returns the next character on stream or -1 if no character is available.
339
debug_fgetpos
Synopsis
int debug_fgetpos(DEBUG_FILE *stream,
long *pos);
Description
debug_fgetpos is equivalent to debug_fseek .
340
debug_fgets
Synopsis
char *debug_fgets(char *s,
int n,
DEBUG_FILE *stream);
Description
debug_fgets reads at most n-1 characters or the characters up to (and including) a newline from the input
stream into the array pointed to by s. A null character is written to the array after the input characters.
debug_fgets returns s on success, or 0 on error or end of file.
341
debug_filesize
Synopsis
int debug_filesize(DEBUG_FILE *stream);
Description
debug_filesize returns the size of the file associated with the stream in bytes.
debug_filesize returns -1 on error.
342
debug_fopen
Synopsis
DEBUG_FILE *debug_fopen(const char *filename,
const char *mode);
Description
debug_fopen opens the filename on the host PC and returns a stream or 0 if the open fails. The filename is a
host PC filename which is opened relative to the debugger working directory. The mode is a string containing
one of:
r open file for reading.
w create file for writing.
a open or create file for writing and position at the end of the file.
r+ open file for reading and writing.
w+ create file for reading and writing.
a+ open or create text file for reading and writing and position at the end of the file.
followed by one of:
t for a text file.
b for a binary file.
debug_fopen returns a stream that can be used to access the file or 0 if the open fails.
343
debug_fprintf
Synopsis
int debug_fprintf(DEBUG_FILE *stream,
const char *format,
...);
Description
debug_fprintf writes to stream, under control of the string pointed to by format that specifies how subsequent
arguments are converted for output. The format string is a standard C printf format string. The actual formatting
is performed on the host by the debugger and therefore debug_fprintf consumes only a very small amount of
code and data space, only the overhead to call the function.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
debug_fprintf returns the number of characters transmitted, or a negative value if an output or encoding error
occurred.
344
debug_fprintf_c
Synopsis
int debug_fprintf_c(DEBUG_FILE *stream,
__code const char *format,
...);
Description
debug_fprintf_c is equivalent to debug_fprintf with the format string in code memory.
345
debug_fputc
Synopsis
int debug_fputc(int c,
DEBUG_FILE *stream);
Description
debug_fputc writes the character c to the output stream.
debug_fputc returns the character written or -1 if an error occurred.
346
debug_fputs
Synopsis
int debug_fputs(const char *s,
DEBUG_FILE *stream);
Description
debug_fputs writes the string pointed to by s to the output stream and appends a new-line character. The
terminating null character is not written.
debug_fputs returns -1 if a write error occurs; otherwise it returns a nonnegative value.
347
debug_fread
Synopsis
int debug_fread(void *ptr,
int size,
int nobj,
DEBUG_FILE *stream);
Description
debug_fread reads from the input stream into the array ptr at most nobj objects of size size.
debug_fread returns the number of objects read. If this number is different from nobj then debug_feof and
debug_ferror can be used to determine status.
348
debug_freopen
Synopsis
DEBUG_FILE *debug_freopen(const char *filename,
const char *mode,
DEBUG_FILE *stream);
Description
debug_freopen is the same as debug_open except the file associated with the stream is closed and the opened
file is then associated with the stream.
349
debug_fscanf
Synopsis
int debug_fscanf(DEBUG_FILE *stream,
const char *format,
...);
Description
debug_fscanf reads from the input stream, under control of the string pointed to by format, that specifies how
subsequent arguments are converted for input. The format string is a standard C scanf format string. The actual
formatting is performed on the host by the debugger and therefore debug_fscanf consumes only a very small
amount of code and data space, only the overhead to call the function.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
debug_fscanf returns number of characters read, or a negative value if an output or encoding error occurred.
350
debug_fscanf_c
Synopsis
int debug_fscanf_c(DEBUG_FILE *stream,
__code const char *format,
...);
Description
debug_fscanf_c is equivalent to debug_fscanf with the format string in code memory.
351
debug_fseek
Synopsis
int debug_fseek(DEBUG_FILE *stream,
long offset,
int origin);
Description
debug_fseek sets the file position for the stream. A subsequent read or write will access data at that position.
The origin can be one of:
0 sets the position to offset bytes from the beginning of the file.
1 sets the position to offset bytes relative to the current position.
2 sets the position to offset bytes from the end of the file.
Note that for text files offset must be zero. debug_fseek returns zero on success, non-zero on error.
352
debug_fsetpos
Synopsis
int debug_fsetpos(DEBUG_FILE *stream,
const long *pos);
Description
debug_fsetpos is equivalent to debug_fseek with 0 as the origin.
353
debug_ftell
Synopsis
long debug_ftell(DEBUG_FILE *stream);
Description
debug_ftell returns the current file position of the stream.
debug_ftell returns -1 on error.
354
debug_fwrite
Synopsis
int debug_fwrite(const void *ptr,
int size,
int nobj,
DEBUG_FILE *stream);
Description
debug_fwrite write to the output stream from the array ptr at most nobj objects of size size.
debug_fwrite returns the number of objects written. If this number is different from nobj then debug_feof and
debug_ferror can be used to determine status.
355
debug_getargs
Synopsis
int debug_getargs(unsigned bufsize,
unsigned char *buf);
Description
debug_getargs stores the debugger command line arguments into the memory pointed at by buf up to a
maximum of bufsize bytes. The command line is stored as a C argc array of null terminated string and the
number of entries is returned as the result.
356
debug_getch
Synopsis
int debug_getch(void);
Description
debug_getch reads one character from the Debug Terminal. This function will block until a character is
available.
357
debug_getchar
Synopsis
int debug_getchar(void);
Description
debug_getchar reads one character from the Debug Terminal. This function uses line input and will therefore
block until characters are available and ENTER has been pressed.
debug_getchar returns the character that has been read.
358
debug_getd
Synopsis
int debug_getd(double *);
Description
debug_getd reads a double from the Debug Terminal. The number is written to the double object pointed to
by d.
debug_getd returns zero on success or -1 on error.
359
debug_getenv
Synopsis
char *debug_getenv(char *name);
Description
debug_getenv returns the value of the environment variable name or 0 if the environment variable cannot be
found.
360
debug_getf
Synopsis
int debug_getf(float *f);
Description
debug_getf reads an float from the Debug Terminal. The number is written to the float object pointed to by f.
debug_getf returns zero on success or -1 on error.
361
debug_geti
Synopsis
int debug_geti(int *i);
Description
debug_geti reads an integer from the Debug Terminal. If the number starts with 0x it is interpreted as a
hexadecimal number, if it starts with 0 it is interpreted as an octal number, if it starts with 0b it is interpreted as
a binary number, otherwise it is interpreted as a decimal number. The number is written to the integer object
pointed to by i.
debug_geti returns zero on success or -1 on error.
362
debug_getl
Synopsis
int debug_getl(long *l);
Description
debug_getl reads a long from the Debug Terminal. If the number starts with 0x it is interpreted as a
hexadecimal number, if it starts with 0 it is interpreted as an octal number, if it starts with it is interpreted as
a binary number, otherwise it is interpreted as a decimal number. The number is written to the long object
pointed to by l.
debug_getl returns zero on success or -1 on error.
363
debug_getll
Synopsis
int debug_getll(long long *ll);
Description
debug_getll reads a long long from the Debug Terminal. If the number starts with 0x it is interpreted as a
hexadecimal number, if it starts with 0 it is interpreted as an octal number, if it starts with 0b it is interpreted as
a binary number, otherwise it is interpreted as a decimal number. The number is written to the long long object
pointed to by ll.
debug_getll returns zero on success or -1 on error.
364
debug_gets
Synopsis
char *debug_gets(char *s);
Description
debug_gets reads a string from the Debug Terminal in memory pointed at by s. This function will block until
ENTER has been pressed.
debug_gets returns the value of s.
365
debug_getu
Synopsis
int debug_getu(unsigned *u);
Description
debug_getu reads an unsigned integer from the Debug Terminal. If the number starts with 0x it is interpreted
as a hexadecimal number, if it starts with 0 it is interpreted as an octal number, if it starts with 0b it is interpreted
as a binary number, otherwise it is interpreted as a decimal number. The number is written to the unsigned
integer object pointed to by u.
debug_getu returns zero on success or -1 on error.
366
debug_getul
Synopsis
int debug_getul(unsigned long *ul);
Description
debug_getul reads an unsigned long from the Debug Terminal. If the number starts with 0x it is interpreted as
a hexadecimal number, if it starts with 0 it is interpreted as an octal number, if it starts with 0b it is interpreted
as a binary number, otherwise it is interpreted as a decimal number. The number is written to the long object
pointed to by ul.
debug_getul returns zero on success or -1 on error.
367
debug_getull
Synopsis
int debug_getull(unsigned long long *ull);
Description
debug_getull reads an unsigned long long from the Debug Terminal. If the number starts with 0x it is
interpreted as a hexadecimal number, if it starts with 0 it is interpreted as an octal number, if it starts with 0b it
is interpreted as a binary number, otherwise it is interpreted as a decimal number. The number is written to the
long long object pointed to by ull.
debug_getull returns zero on success or -1 on error.
368
debug_kbhit
Synopsis
int debug_kbhit(void);
Description
debug_kbhit polls the Debug Terminal for a character and returns a non-zero value if a character is available or 0
if not.
369
debug_loadsymbols
Synopsis
void debug_loadsymbols(const char *filename,
const void *address,
const char *breaksymbol);
Description
debug_loadsymbols instructs the debugger to load the debugging symbols in the file denoted by filename.
The filename is a (macro expanded) host PC filename which is relative to the debugger working directory. The
address is the load address which is required for debugging position independent executables, supply NULL for
regular executables. The breaksymbol is the name of a symbol in the filename to set a temporary breakpoint on
or NULL.
370
debug_perror
Synopsis
void debug_perror(const char *s);
Description
debug_perror displays the optional string s on the Debug Terminal together with a string corresponding to the
errno value of the last Debug IO operation.
371
debug_printf
Synopsis
int debug_printf(const char *format,
...);
Description
debug_printf writes to the Debug Terminal, under control of the string pointed to by format that specifies
how subsequent arguments are converted for output. The format string is a standard C printf format string. The
actual formatting is performed on the host by the debugger and therefore debug_printf consumes only a very
small amount of code and data space, only the overhead to call the function.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
debug_printf returns the number of characters transmitted, or a negative value if an output or encoding error
occurred.
372
debug_printf_c
Synopsis
int debug_printf_c(__code const char *format,
...);
Description
debug_printf_c is equivalent to debug_printf with the format string in code memory.
373
debug_putchar
Synopsis
int debug_putchar(int c);
Description
debug_putchar write the character c to the Debug Terminal.
debug_putchar returns the character written or -1 if a write error occurs.
374
debug_puts
Synopsis
int debug_puts(const char *);
Description
debug_puts writes the string s to the Debug Terminal followed by a new-line character.
debug_puts returns -1 if a write error occurs, otherwise it returns a nonnegative value.
375
debug_remove
Synopsis
int debug_remove(const char *filename);
Description
debug_remove removes the filename denoted by filename and returns 0 on success or -1 on error. The
filename is a host PC filename which is relative to the debugger working directory.
376
debug_rename
Synopsis
int debug_rename(const char *oldfilename,
const char *newfilename);
Description
debug_rename renames the file denoted by oldpath to newpath and returns zero on success or non-zero on
error. The oldpath and newpath are host PC filenames which are relative to the debugger working directory.
377
debug_rewind
Synopsis
void debug_rewind(DEBUG_FILE *stream);
Description
debug_rewind sets the current file position of the stream to the beginning of the file and clears any error and
end of file conditions.
378
debug_runtime_error
Synopsis
void debug_runtime_error(const char *error);
Description
debug_runtime_error causes the debugger to stop the target, position the cursor at the line that called
debug_runtime_error, and display the null-terminated string pointed to by error.
379
debug_scanf
Synopsis
int debug_scanf(const char *format,
...);
Description
debug_scanf reads from the Debug Terminal, under control of the string pointed to by format that specifies
how subsequent arguments are converted for input. The format string is a standard C scanf format string. The
actual formatting is performed on the host by the debugger and therefore debug_scanf consumes only a very
small amount of code and data space, only the overhead to call the function.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
debug_scanf returns number of characters read, or a negative value if an output or encoding error occurred.
380
debug_scanf_c
Synopsis
int debug_scanf_c(__code const char *format,
...);
Description
debug_scanf_c is equivalent to debug_scanf with the format string in code memory.
381
debug_system
Synopsis
int debug_system(char *command);
Description
debug_system executes the command with the host command line interpreter and returns the commands exit
status.
382
debug_time
Synopsis
long debug_time(long *ptr);
Description
debug_time returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated
universal time (UTC), according to the system clock of the host computer. The return value is stored in *ptr if ptr
is not NULL.
383
debug_tmpfile
Synopsis
DEBUG_FILE *debug_tmpfile(void);
Description
debug_tmpfile creates a temporary file on the host PC which is deleted when the stream is closed.
384
debug_tmpnam
Synopsis
char *debug_tmpnam(char *str);
Description
debug_tmpnam returns a unique temporary filename. If str is NULL then a static buffer is used to store the
filename, otherwise the filename is stored in str. On success a pointer to the string is returned, on failure 0 is
returned.
385
debug_ungetc
Synopsis
int debug_ungetc(int c,
DEBUG_FILE *stream);
Description
debug_ungetc pushes the character c onto the input stream. If successful c is returned, otherwise -1 is returned.
386
debug_unloadsymbols
Synopsis
void debug_unloadsymbols(const char *filename);
Description
debug_unloadsymbols instructs the debugger to unload the debugging symbols (previously loaded by a call to
debug_loadsymbols) in the file denoted by filename. The filename is a host PC filename which is relative to the
debugger working directory.
387
debug_vfprintf
Synopsis
int debug_vfprintf(DEBUG_FILE *stream,
const char *format,
__va_list);
Description
debug_vfprintf is equivalent to debug_fprintf with arguments passed using stdarg.h rather than a variable
number of arguments.
388
debug_vfscanf
Synopsis
int debug_vfscanf(DEBUG_FILE *stream,
const char *format,
__va_list);
Description
debug_vfscanf is equivalent to debug_fscanf with arguments passed using stdarg.h rather than a variable
number of arguments.
389
debug_vprintf
Synopsis
int debug_vprintf(const char *format,
__va_list);
Description
debug_vprintf is equivalent to debug_printf with arguments passed using stdarg.h rather than a variable
number of arguments.
390
debug_vscanf
Synopsis
int debug_vscanf(const char *format,
__va_list);
Description
debug_vscanf is equivalent to debug_scanf with arguments passed using stdarg.h rather than a variable
number of arguments.
391
<errno.h>
API Summary
Error numbers
EDOM
Domain error
EILSEQ
EINVAL
Invalid argument
ENOMEM
No memory available
ERANGE
Macros
errno
392
EDOM
Synopsis
#define EDOM
...
Description
EDOM - an input argument is outside the defined domain of a mathematical function.
393
EILSEQ
Synopsis
#define EILSEQ
...
Description
EILSEQ - A wide-character code has been detected that does not correspond to a valid character, or a byte
sequence does not form a valid wide-character code.
394
EINVAL
Synopsis
#define EINVAL
0x06
Description
EINVAL - An argument was invalid, or a combination of arguments was invalid.
395
ENOMEM
Synopsis
#define ENOMEM
0x05
Description
ENOMEM - no memory can be allocated by a function in the library. Note that malloc, calloc, and realloc do not
set errno to ENOMEM on failure, but other library routines (such as duplocale) may set errno to ENOMEM when
memory allocation fails.
396
ERANGE
Synopsis
#define ERANGE
...
Description
ERANGE - the result of the function is too large (overflow) or too small (underflow) to be represented in the
available space.
397
errno
Synopsis
int errno;
Description
errno is treated as an writable l-value, but the implementation of how the l-value is read an written is hidden
from the user.
The value of errno is zero at program startup, but is never set to zero by any library function. The value of errno
may be set to a nonzero value by a library function, and this effect is documented in each function that does so.
Note
The ISO standard does not specify whether errno is a macro or an identifier declared with external linkage.
Portable programs must not make assumptions about the implementation of errno.
In this implementation, errno expands to a function call to __errno (MSP430, AVR, MAXQ) or
__aeabi_errno_addr (ARM) that returns a pointer to a volatile int. This function can be implemented by the
application to provide a thread-specific errno.
398
<float.h>
API Summary
Double exponent minimum and maximum values
DBL_MAX_10_EXP
DBL_MAX_EXP
DBL_MIN_10_EXP
DBL_MIN_EXP
Implementation
DBL_DIG
DBL_MANT_DIG
DECIMAL_DIG
FLT_DIG
FLT_EVAL_METHOD
FLT_MANT_DIG
FLT_RADIX
FLT_ROUNDS
FLT_MAX_EXP
FLT_MIN_10_EXP
FLT_MIN_EXP
DBL_MAX
DBL_MIN
FLT_MAX
FLT_MIN
399
DBL_DIG
Synopsis
#define DBL_DIG
15
Description
DBL_DIG specifies The number of digits of precision of a double.
400
DBL_EPSILON
Synopsis
#define DBL_EPSILON 2.2204460492503131E-16
Description
DBL_EPSILON the minimum positive number such that 1.0 + DBL_EPSILON != 1.0.
401
DBL_MANT_DIG
Synopsis
#define DBL_MANT_DIG
53
Description
DBL_MANT_DIG specifies the number of base FLT_RADIX digits in the mantissa part of a double.
402
DBL_MAX
Synopsis
#define DBL_MAX
1.7976931348623157E+308
Description
DBL_MAX is the maximum value of a double.
403
DBL_MAX_10_EXP
Synopsis
#define DBL_MAX_10_EXP
+308
Description
DBL_MAX_10_EXP is the maximum value in base 10 of the exponent part of a double.
404
DBL_MAX_EXP
Synopsis
#define DBL_MAX_EXP
+1024
Description
DBL_MAX_EXP is the maximum value of base FLT_RADIX in the exponent part of a double.
405
DBL_MIN
Synopsis
#define DBL_MIN
2.2250738585072014E-308
Description
DBL_MIN is the minimum value of a double.
406
DBL_MIN_10_EXP
Synopsis
#define DBL_MIN_10_EXP
-307
Description
DBL_MIN_10_EXP is the minimum value in base 10 of the exponent part of a double.
407
DBL_MIN_EXP
Synopsis
#define DBL_MIN_EXP
-1021
Description
DBL_MIN_EXP is the minimum value of base FLT_RADIX in the exponent part of a double.
408
DECIMAL_DIG
Synopsis
#define DECIMAL_DIG
17
Description
DECIMAL_DIG specifies the number of decimal digits that can be rounded to a floating-point number without
change to the value.
409
FLT_DIG
Synopsis
#define FLT_DIG
Description
FLT_DIG specifies The number of digits of precision of a float.
410
FLT_EPSILON
Synopsis
#define FLT_EPSILON 1.19209290E-07F // decimal constant
Description
FLT_EPSILON the minimum positive number such that 1.0 + FLT_EPSILON != 1.0.
411
FLT_EVAL_METHOD
Synopsis
#define FLT_EVAL_METHOD 0
Description
FLT_EVAL_METHOD specifies that all operations and constants are evaluated to the range and precision of the
type.
412
FLT_MANT_DIG
Synopsis
#define FLT_MANT_DIG
24
Description
FLT_MANT_DIG specifies the number of base FLT_RADIX digits in the mantissa part of a float.
413
FLT_MAX
Synopsis
#define FLT_MAX
3.40282347E+38F
Description
FLT_MAX is the maximum value of a float.
414
FLT_MAX_10_EXP
Synopsis
#define FLT_MAX_10_EXP
+38
Description
FLT_MAX_10_EXP is the maximum value in base 10 of the exponent part of a float.
415
FLT_MAX_EXP
Synopsis
#define FLT_MAX_EXP
+128
Description
FLT_MAX_EXP is the maximum value of base FLT_RADIX in the exponent part of a float.
416
FLT_MIN
Synopsis
#define FLT_MIN
1.17549435E-38F
Description
FLT_MIN is the minimum value of a float.
417
FLT_MIN_10_EXP
Synopsis
#define FLT_MIN_10_EXP
-37
Description
FLT_MIN_10_EXP is the minimum value in base 10 of the exponent part of a float.
418
FLT_MIN_EXP
Synopsis
#define FLT_MIN_EXP
-125
Description
FLT_MIN_EXP is the minimum value of base FLT_RADIX in the exponent part of a float.
419
FLT_RADIX
Synopsis
#define FLT_RADIX
Description
FLT_RADIX specifies the radix of the exponent representation.
420
FLT_ROUNDS
Synopsis
#define FLT_ROUNDS 1
Description
FLT_ROUNDS specifies the rounding mode of floating-point addition is round to nearest.
421
<iso646.h>
Overview
The header <iso646.h> defines macros that expand to the corresponding tokens to ease writing C programs
with keyboards that do not have keys for frequently-used operators.
API Summary
Macros
and
and_eq
bitand
bitor
compl
not
not_eq
or
or_eq
xor
xor_eq
422
and
Synopsis
#define and
&&
Description
and defines the alternative spelling for &&.
423
and_eq
Synopsis
#define and_eq
&=
Description
and_eq defines the alternative spelling for &=.
424
bitand
Synopsis
#define bitand
&
Description
bitand defines the alternative spelling for &.
425
bitor
Synopsis
#define bitor
Description
bitor defines the alternative spelling for |.
426
compl
Synopsis
#define compl
Description
compl defines the alternative spelling for ~.
427
not
Synopsis
#define not
Description
not defines the alternative spelling for !.
428
not_eq
Synopsis
#define not_eq
!=
Description
not_eq defines the alternative spelling for !=.
429
or
Synopsis
#define or
||
Description
or defines the alternative spelling for ||.
430
or_eq
Synopsis
#define or_eq
|=
Description
or_eq defines the alternative spelling for |=.
431
xor
Synopsis
#define xor
Description
xor defines the alternative spelling for ^.
432
xor_eq
Synopsis
#define xor_eq
^=
Description
xor_eq defines the alternative spelling for ^=.
433
<limits.h>
API Summary
Long integer minimum and maximum values
LONG_MAX
LONG_MIN
ULONG_MAX
CHAR_MIN
SCHAR_MAX
SCHAR_MIN
UCHAR_MAX
LLONG_MIN
ULLONG_MAX
SHRT_MIN
USHRT_MAX
INT_MIN
UINT_MAX
Type sizes
CHAR_BIT
Multi-byte values
MB_LEN_MAX
434
CHAR_BIT
Synopsis
#define CHAR_BIT
Description
CHAR_BIT is the number of bits for smallest object that is not a bit-field (byte).
435
CHAR_MAX
Synopsis
#define CHAR_MAX
255
Description
CHAR_MAX is the maximum value for an object of type char.
436
CHAR_MIN
Synopsis
#define CHAR_MIN
Description
CHAR_MIN is the minimum value for an object of type char.
437
INT_MAX
Synopsis
#define INT_MAX
2147483647
Description
INT_MAX is the maximum value for an object of type int.
438
INT_MIN
Synopsis
#define INT_MIN
(-2147483647 - 1)
Description
INT_MIN is the minimum value for an object of type int.
439
LLONG_MAX
Synopsis
#define LLONG_MAX
9223372036854775807LL
Description
LLONG_MAX is the maximum value for an object of type long long int.
440
LLONG_MIN
Synopsis
#define LLONG_MIN
(-9223372036854775807LL - 1)
Description
LLONG_MIN is the minimum value for an object of type long long int.
441
LONG_MAX
Synopsis
#define LONG_MAX
2147483647L
Description
LONG_MAX is the maximum value for an object of type long int.
442
LONG_MIN
Synopsis
#define LONG_MIN
(-2147483647L - 1)
Description
LONG_MIN is the minimum value for an object of type long int.
443
MB_LEN_MAX
Synopsis
#define MB_LEN_MAX
Description
MB_LEN_MAX is the maximum number of bytes in a multi-byte character for any supported locale. Unicode (ISO
10646) characters between 0 and 10FFFF inclusive are supported which convert to a maximum of four bytes in
the UTF-8 encoding.
444
SCHAR_MAX
Synopsis
#define SCHAR_MAX
127
Description
SCHAR_MAX is the maximum value for an object of type signed char.
445
SCHAR_MIN
Synopsis
#define SCHAR_MIN
(-128)
Description
SCHAR_MIN is the minimum value for an object of type signed char.
446
SHRT_MAX
Synopsis
#define SHRT_MAX
32767
Description
SHRT_MAX is the minimum value for an object of type short int.
447
SHRT_MIN
Synopsis
#define SHRT_MIN
(-32767 - 1)
Description
SHRT_MIN is the minimum value for an object of type short int.
448
UCHAR_MAX
Synopsis
#define UCHAR_MAX
255
Description
UCHAR_MAX is the maximum value for an object of type unsigned char.
449
UINT_MAX
Synopsis
#define UINT_MAX
4294967295U
Description
UINT_MAX is the maximum value for an object of type unsigned int.
450
ULLONG_MAX
Synopsis
#define ULLONG_MAX 18446744073709551615ULL
Description
ULLONG_MAX is the maximum value for an object of type unsigned long long int.
451
ULONG_MAX
Synopsis
#define ULONG_MAX
4294967295UL
Description
ULONG_MAX is the maximum value for an object of type unsigned long int.
452
USHRT_MAX
Synopsis
#define USHRT_MAX
65535
Description
USHRT_MAX is the minimum value for an object of type unsigned short int.
453
<locale.h>
API Summary
Structures
lconv
Functions
localeconv
setlocale
Set Locale
454
lconv
Synopsis
typedef struct {
char *decimal_point;
char *thousands_sep;
char *grouping;
char *int_curr_symbol;
char *currency_symbol;
char *mon_decimal_point;
char *mon_thousands_sep;
char *mon_grouping;
char *positive_sign;
char *negative_sign;
char int_frac_digits;
char frac_digits;
char p_cs_precedes;
char p_sep_by_space;
char n_cs_precedes;
char n_sep_by_space;
char p_sign_posn;
char n_sign_posn;
char int_p_cs_precedes;
char int_n_cs_precedes;
char int_p_sep_by_space;
char int_n_sep_by_space;
char int_p_sign_posn;
char int_n_sign_posn;
} lconv;
Description
lconv structure holds formatting information on how numeric values are to be written. Note that the order of
fields in this structure is not consistent between implementations, nor is it consistent between C89 and C99
standards.
The members decimal_point, grouping, and thousands_sep are controlled by LC_NUMERIC, the remainder by
LC_MONETARY.
The members int_n_cs_precedes, int_n_sep_by_space, int_n_sign_posn, int_p_cs_precedes,
int_p_sep_by_space. and int_p_sign_posn are added by the C99 standard.
We have standardized on the ordering specified by the ARM EABI for the base of this structure. This ordering is
neither that of C89 nor C99.
Member
Description
currency_symbol
decimal_point
frac_digits
455
grouping
int_curr_symbol
int_frac_digits
mon_decimal_point
mon_grouping
mon_thousands_sep
negative_sign
n_cs_precedes
n_sep_by_space
n_sign_posn
positive_sign
p_cs_precedes
p_sep_by_space
p_sign_posn
thousands_sep
456
localeconv
Synopsis
localeconv(void);
Description
localeconv returns a pointer to a structure of type lconv with the corresponding values for the current locale
filled in.
457
setlocale
Synopsis
char *setlocale(int category,
const char *locale);
Description
setlocale sets the current locale. The category parameter can have the following values:
Name
Locale affected
LC_ALL
Entire locale
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
Affects strftime
The locale parameter contains the name of a C locale to set or if NULL is passed the current locale is not
changed.
Return Value
setlocale returns the name of the current locale.
458
<math.h>
API Summary
Comparison Macros
isgreater
Is greater
isgreaterequal
Is greater or equal
isless
Is less
islessequal
Is less or equal
islessgreater
Is less or greater
isunordered
Is unordered
Classification Macros
fpclassify
isfinite
isinf
isnan
isnormal
signbit
Test sign
Trigonometric functions
cos
cosf
sin
sinf
tan
tanf
acosf
asin
asinf
atan
atan2
atan2f
atanf
459
exp
exp2
exp2f
expf
expm1
expm1f
frexp
frexpf
ilogb
ilogbf
ldexp
ldexpf
log
log10
log10f
log1p
log1pf
log2
log2f
logb
logbf
logf
scalbln
Scale a double
scalblnf
Scale a float
scalbn
Scale a double
scalbnf
Scale a float
ceilf
floor
floorf
fmod
fmodf
llrint
llrintf
460
llround
llroundf
lrint
lrintf
lround
lroundf
modf
modff
nearbyint
nearbyintf
remainder
remainderf
remquo
remquof
rint
rintf
round
roundf
trunc
truncf
Power functions
cbrt
cbrtf
hypot
hypotf
pow
powf
sqrt
sqrtf
fabsf
fdimf
461
fmax
fmaxf
fmin
fminf
Hyperbolic functions
cosh
coshf
sinh
sinhf
tanh
tanhf
acoshf
asinh
asinhf
atanh
atanhf
fmaf
copysignf
nextafter
nextafterf
erfc
erfcf
erff
lgamma
lgammaf
tgamma
tgammaf
462
acos
Synopsis
double acos(double x);
Description
acos returns the principal value, in radians, of the inverse circular cosine of x. The principal value lies in the
interval [0, PI] radians.
If |x| > 1, errno is set to EDOM and acos returns HUGE_VAL.
If x is NaN, acos returns x. If |x| > 1, acos returns NaN.
463
acosf
Synopsis
float acosf(float x);
Description
acosf returns the principal value, in radians, of the inverse circular cosine of x. The principal value lies in the
interval [0, PI] radians.
If |a| 1, errno is set to EDOM and acosf returns HUGE_VAL.
If x is NaN, acosf returns x. If |x| > 1, acosf returns NaN.
464
acosh
Synopsis
double acosh(double x);
Description
acosh returns the non-negative inverse hyperbolic cosine of x.
acosh(x) is defined as log(x + sqrt(x^2 1)), assuming completely accurate computation.
If x < 1, errno is set to EDOM and acosh returns HUGE_VAL.
If x < 1, acosh returns NaN.
If x is NaN, acosh returns NaN.
465
acoshf
Synopsis
float acoshf(float x);
Description
acoshf returns the non-negative inverse hyperbolic cosine of x.
acosh(x) is defined as log(x + sqrt(x^2 1)), assuming completely accurate computation.
If x < 1, errno is set to EDOM and acoshf returns HUGE_VALF.
If x < 1, acoshf returns NaN.
If x is NaN, acoshf returns that NaN.
466
asin
Synopsis
double asin(double x);
Description
asin returns the principal value, in radians, of the inverse circular sine of x. The principal value lies in the interval
[, +] radians.
If |x| > 1, errno is set to EDOM and asin returns HUGE_VAL.
If x is NaN, asin returns x. If |x| > 1, asin returns NaN.
467
asinf
Synopsis
float asinf(float x);
Description
asinf returns the principal value, in radians, of the inverse circular sine of val. The principal value lies in the
interval [, +] radians.
If |x| > 1, errno is set to EDOM and asinf returns HUGE_VALF.
If x is NaN, asinf returns x. If |x| > 1, asinf returns NaN.
468
asinh
Synopsis
double asinh(double x);
Description
asinh calculates the hyperbolic sine of x.
If |x| > ~709.782, errno is set to EDOM and asinh returns HUGE_VAL.
If x is +, , or NaN, asinh returns |x|. If |x| > ~709.782, asinh returns + or depending upon the sign of x.
469
asinhf
Synopsis
float asinhf(float x);
Description
asinhf calculates the hyperbolic sine of x.
If |x| > ~88.7228, errnois set to EDOM and asinhf returns HUGE_VALF.
If x is +, , or NaN, asinhf returns |x|. If |x| > ~88.7228, asinhf returns + or depending upon the sign of x.
470
atan
Synopsis
double atan(double x);
Description
atan returns the principal value, in radians, of the inverse circular tangent of x. The principal value lies in the
interval [, +] radians.
471
atan2
Synopsis
double atan2(double x,
double y);
Description
atan2 returns the value, in radians, of the inverse circular tangent of y divided by x using the signs of x and y to
compute the quadrant of the return value. The principal value lies in the interval [/2, +] radians. If x = y =
0, errno is set to EDOM and atan2 returns HUGE_VAL.
atan2(x, NaN) is NaN.
atan2(NaN, x) is NaN.
atan2(0, +(anything but NaN)) is 0.
atan2(0, (anything but NaN)) is .
atan2((anything but 0 and NaN), 0) is .
atan2((anything but and NaN), +) is 0.
atan2((anything but and NaN), ) is .
atan2(, +) is .
atan2(, ) is .
atan2(, (anything but 0, NaN, and )) is .
472
atan2f
Synopsis
float atan2f(float y,
float x);
Description
atan2f returns the value, in radians, of the inverse circular tangent of y divided by x using the signs of x and y to
compute the quadrant of the return value. The principal value lies in the interval [, +] radians.
If x = y = 0, errno is set to EDOM and atan2f returns HUGE_VALF.
atan2f(x, NaN) is NaN.
atan2f(NaN, x) is NaN.
atan2f(0, +(anything but NaN)) is 0.
atan2f(0, (anything but NaN)) is .
atan2f((anything but 0 and NaN), 0) is .
atan2f((anything but and NaN), +) is 0.
atan2f((anything but and NaN), ) is .
atan2f(, +) is .
atan2f(, ) is .
atan2f(, (anything but 0, NaN, and )) is .
473
atanf
Synopsis
float atanf(float x);
Description
atanf returns the principal value, in radians, of the inverse circular tangent of x. The principal value lies in the
interval [, +] radians.
474
atanh
Synopsis
double atanh(double x);
Description
atanh returns the inverse hyperbolic tangent of x.
If |x| 1, errno is set to EDOM and atanh returns HUGE_VAL.
If |x| > 1 atanh returns NaN.
If x is NaN, atanh returns that NaN.
If x is 1, atanh returns .
If x is 1, atanh returns .
475
atanhf
Synopsis
float atanhf(float x);
Description
atanhf returns the inverse hyperbolic tangent of x.
If |x| > 1 atanhf returns NaN. If x is NaN, atanhf returns that NaN. If x is 1, atanhf returns . If x is 1, atanhf
returns .
476
cbrt
Synopsis
double cbrt(double x);
Description
cbrt computes the cube root of x.
477
cbrtf
Synopsis
float cbrtf(float x);
Description
cbrtf computes the cube root of x.
478
ceil
Synopsis
double ceil(double x);
Description
ceil computes the smallest integer value not less than x.
ceil (0) is 0. ceil ( ) is .
479
ceilf
Synopsis
float ceilf(float x);
Description
ceilf computes the smallest integer value not less than x.
ceilf (0) is 0. ceilf ( ) is .
480
copysign
Synopsis
double copysign(double x,
double y);
Description
copysign returns a value with the magnitude of x and the sign of y.
481
copysignf
Synopsis
float copysignf(float x,
float y);
Description
copysignf returns a value with the magnitude of x and the sign of y.
482
cos
Synopsis
double cos(double x);
Description
cos returns the radian circular cosine of x.
If |x| > 10^9, errno is set to EDOM and cos returns HUGE_VAL.
If x is NaN, cos returns x. If |x| is , cos returns NaN.
483
cosf
Synopsis
float cosf(float x);
Description
cosf returns the radian circular cosine of x.
If |x| > 10^9, errno is set to EDOM and cosf returns HUGE_VALF.
If x is NaN, cosf returns x. If |x| is , cosf returns NaN.
484
cosh
Synopsis
double cosh(double x);
Description
cosh calculates the hyperbolic cosine of x.
If |x| > ~709.782, errno is set to EDOM and cosh returns HUGE_VAL.
If x is +, , or NaN, cosh returns |x|.> If |x| > ~709.782, cosh returns + or depending upon the sign of x.
485
coshf
Synopsis
float coshf(float x);
Description
coshf calculates the hyperbolic sine of x.
If |x| > ~88.7228, errno is set to EDOM and coshf returns HUGE_VALF.
If x is +, , or NaN, coshf returns |x|.
If |x| > ~88.7228, coshf returns + or depending upon the sign of x.
486
erf
Synopsis
double erf(double x);
Description
erf returns the error function for x.
487
erfc
Synopsis
double erfc(double x);
Description
erfc returns the complementary error function for x.
488
erfcf
Synopsis
float erfcf(float x);
Description
erfcf returns the complementary error function for x.
489
erff
Synopsis
float erff(float x);
Description
erff returns the error function for x.
490
exp
Synopsis
double exp(double x);
Description
exp computes the base-e exponential of x.
If |x| > ~709.782, errno is set to EDOM and exp returns HUGE_VAL.
If x is NaN, exp returns NaN.
If x is , exp returns .
If x is , exp returns 0.
491
exp2
Synopsis
double exp2(double x);
Description
exp2 returns 2 raised to the power of x.
492
exp2f
Synopsis
float exp2f(float x);
Description
exp2f returns 2 raised to the power of x.
493
expf
Synopsis
float expf(float x);
Description
expf computes the base-e exponential of x.
If |x| > ~88.722, errno is set to EDOM and expf returns HUGE_VALF. If x is NaN, expf returns NaN.
If x is , expf returns .
If x is , expf returns 0.
494
expm1
Synopsis
double expm1(double x);
Description
expm1 returns e raised to the power of x minus one.
495
expm1f
Synopsis
float expm1f(float x);
Description
expm1f returns e raised to the power of x minus one.
496
fabs
Synopsis
double fabs(double x);
497
fabsf
Synopsis
float fabsf(float x);
Description
fabsf computes the absolute value of the floating-point number x.
498
fdim
Synopsis
double fdim(double x,
double y);
Description
fdim returns the positive difference between x and y.
499
fdimf
Synopsis
float fdimf(float x,
float y);
Description
fdimf returns the positive difference between x and y.
500
floor
Synopsis
double floor(double);
501
floorf
Synopsis
float floorf(float);
502
fma
Synopsis
double fma(double x,
double y,
double z);
Description
fma computes x y + z with a single rounding.
503
fmaf
Synopsis
float fmaf(float x,
float y,
float z);
Description
fmaf computes x y + z with a single rounding.
504
fmax
Synopsis
double fmax(double x,
double y);
Description
fmax determines the maximum of x and y.
fmax (NaN, y) is y. fmax (x, NaN) is x.
505
fmaxf
Synopsis
float fmaxf(float x,
float y);
Description
fmaxf determines the maximum of x and y.
fmaxf (NaN, y) is y. fmaxf(x, NaN) is x.
506
fmin
Synopsis
double fmin(double x,
double y);
Description
fmin determines the minimum of x and y.
fmin (NaN, y) is y. fmin (x, NaN) is x.
507
fminf
Synopsis
float fminf(float x,
float y);
Description
fminf determines the minimum of x and y.
fminf (NaN, y) is y. fminf (x, NaN) is x.
508
fmod
Synopsis
double fmod(double x,
double y);
Description
fmod computes the floating-point remainder of x divided by y. #b #this returns the value x n y, for some
integer n such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y.
fmod (NaN, y) is NaN. fmod (x, NaN) is NaN. fmod ( 0, y) is 0 for y not zero.
fmod (, y) is NaN.
fmod (x, 0) is NaN.
fmod (x, ) is x for x not infinite.
509
fmodf
Synopsis
float fmodf(float x,
float y);
Description
fmodf computes the floating-point remainder of x divided by y. fmodf returns the value x n y, for some
integer n such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y.
fmodf (NaN, y) is NaN. fmodf (x, NaN) is NaN. fmodf ( 0, y) is 0 for y not zero.
fmodf (, y) is NaN.
fmodf (x, 0) is NaN.
fmodf (x, ) is x for x not infinite.
510
fpclassify
Synopsis
#define fpclassify(x) (__is_float32(x) ? __float32_classify(x) : __float64_classify(x))
Description
fpclassify classifies x as NaN, infinite, normal, subnormal, zero, or into another implementation-defined
category. fpclassify returns one of:
FP_ZERO
FP_SUBNORMAL
FP_NORMAL
FP_INFINITE
FP_NAN
511
frexp
Synopsis
double frexp(double x,
int *exp);
Description
frexp breaks a floating-point number into a normalized fraction and an integral power of 2.
frexp stores power of two in the int object pointed to by exp and returns the value x, such that x has a
magnitude in the interval [1/2, 1) or zero, and value equals x * 2^exp.
If x is zero, both parts of the result are zero.
If x is or NaN, frexp returns x and stores zero into the int object pointed to by exp.
512
frexpf
Synopsis
float frexpf(float x,
int *exp);
Description
frexpf breaks a floating-point number into a normalized fraction and an integral power of 2.
frexpf stores power of two in the int object pointed to by frexpf and returns the value x, such that x has a
magnitude in the interval [, 1) or zero, and value equals x * 2^exp.
If x is zero, both parts of the result are zero.
If x is or NaN, frexpf returns x and stores zero into the int object pointed to by exp.
513
hypot
Synopsis
double hypot(double x,
double y);
Description
hypot computes the square root of the sum of the squares of x and y, sqrt(x*x + y*y), without undue overflow or
underflow. If x and y are the lengths of the sides of a right-angled triangle, then hypot computes the length of
the hypotenuse.
If x or y is + or , hypot returns .
If x or y is NaN, hypot returns NaN.
514
hypotf
Synopsis
float hypotf(float x,
float y);
Description
hypotf computes the square root of the sum of the squares of x and y, sqrtf(x*x + y*y), without undue overflow
or underflow. If x and y are the lengths of the sides of a right-angled triangle, then hypotf computes the length
of the hypotenuse.
If x or y is + or , hypotf returns . If x or y is NaN, hypotf returns NaN.
515
ilogb
Synopsis
int ilogb(double x);
Description
ilogb returns the integral part of the logarithm of x, using FLT_RADIX as the base for the logarithm.
516
ilogbf
Synopsis
int ilogbf(float x);
Description
ilogbf returns the integral part of the logarithm of x, using FLT_RADIX as the base for the logarithm.
517
isfinite
Synopsis
#define isfinite(x) (sizeof(x) == sizeof(float) ? __float32_isfinite(x) : __float64_isfinite(x))
Description
isfinite determines whether x is a finite value (zero, subnormal, or normal, and not infinite or NaN). isfinite
returns a non-zero value if and only if x has a finite value.
518
isgreater
Synopsis
#define isgreater(x,y) (!isunordered(x, y) && (x > y))
Description
isgreater returns whether x is greater than y.
519
isgreaterequal
Synopsis
#define isgreaterequal(x,y) (!isunordered(x, y) && (x >= y))
Description
isgreaterequal returns whether x is greater than or equal to y.
520
isinf
Synopsis
#define isinf(x) (sizeof(x) == sizeof(float) ? __float32_isinf(x) : __float64_isinf(x))
Description
isinf determines whether x is an infinity (positive or negative). The determination is based on the type of the
argument.
521
isless
Synopsis
#define isless(x,y) (!isunordered(x, y) && (x < y))
Description
isless returns whether x is less than y.
522
islessequal
Synopsis
#define islessequal(x,y) (!isunordered(x, y) && (x <= y))
Description
islessequal returns whether x is less than or equal to y.
523
islessgreater
Synopsis
#define islessgreater(x,y) (!isunordered(x, y) && (x < y || x > y))
Description
islessgreater returns whether x is less than or greater than y.
524
isnan
Synopsis
#define isnan(x) (sizeof(x) == sizeof(float) ? __float32_isnan(x) : __float64_isnan(x))
Description
isnan determines whether x is a NaN. The determination is based on the type of the argument.
525
isnormal
Synopsis
#define isnormal(x) (sizeof(x) == sizeof(float) ? __float32_isnormal(x) : __float64_isnormal(x))
Description
isnormal determines whether x is a normal value (zero, subnormal, or normal, and not infinite or NaN).. isnormal
returns a non-zero value if and only if x has a normal value.
526
isunordered
Synopsis
#define isunordered(a,b) (fpclassify(a) == FP_NAN || fpclassify(b) == FP_NAN)
Description
isunordered returns whether x or y are unordered values.
527
ldexp
Synopsis
double ldexp(double x,
int exp);
Description
ldexp multiplies a floating-point number by an integral power of 2.
ldexp returns x * 2^exp.
If the result overflows, errno is set to ERANGE and ldexp returns HUGE_VALF.
If x is or NaN, ldexp returns x. If the result overflows, ldexp returns .
528
ldexpf
Synopsis
float ldexpf(float x,
int exp);
Description
ldexpf multiplies a floating-point number by an integral power of 2.
ldexpf returns x * 2^exp. If the result overflows, errno is set to ERANGE and ldexpf returns HUGE_VALF.
If x is or NaN, ldexpf returns x. If the result overflows, ldexpf returns .
529
lgamma
Synopsis
double lgamma(double x);
Description
lgamma returns the natural logarithm of the gamma function for x.
530
lgammaf
Synopsis
float lgammaf(float x);
Description
lgammaf returns the natural logarithm of the gamma function for x.
531
llrint
Synopsis
long long int llrint(double x);
Description
llrint rounds x to an integral value and returns it as a long long int.
532
llrintf
Synopsis
long long int llrintf(float x);
Description
llrintf rounds x to an integral value and returns it as a long long int.
533
llround
Synopsis
long long int llround(double x);
Description
llround rounds x to an integral value, with halfway cases rounded away from zero, and returns it as a long long
int.
534
llroundf
Synopsis
long long int llroundf(float x);
Description
llroundf rounds x to an integral value, with halfway cases rounded away from zero, and returns it as a long long
int.
535
log
Synopsis
double log(double x);
Description
log computes the base-e logarithm of x.
If x = 0, errno is set to ERANGE and log returns HUGE_VAL. If x < 0, errno is set to EDOM and log returns
HUGE_VAL.
If x < 0 or x = , log returns NaN.
If x = 0, log returns .
If x = , log returns .
If x = NaN, log returns x.
536
log10
Synopsis
double log10(double x);
Description
log10 computes the base-10 logarithm of x.
If x = 0, errno is set to ERANGE and log10 returns HUGE_VAL. If x < 0, errno is set to EDOM and log10 returns
HUGE_VAL.
If x < 0 or x = , log10 returns NaN.
If x = 0, log10 returns .
If x = , log10 returns .
If x = NaN, log10 returns x.
537
log10f
Synopsis
float log10f(float x);
Description
log10f computes the base-10 logarithm of x.
If x = 0, errno is set to ERANGE and log10f returns HUGE_VALF. If x < 0, errno is set to EDOM and log10f
returns HUGE_VALF.
If x < 0 or x = , log10f returns NaN.
If x = 0, log10f returns .
If x = , log10f returns .
If x = NaN, log10f returns x.
538
log1p
Synopsis
double log1p(double x);
Description
log1p computes the base-e logarithm of x plus one.
539
log1pf
Synopsis
float log1pf(float x);
Description
log1pf computes the base-e logarithm of x plus one.
540
log2
Synopsis
double log2(double x);
Description
log2 computes the base-2 logarithm of x.
541
log2f
Synopsis
float log2f(float x);
Description
log2f computes the base-2 logarithm of x.
542
logb
Synopsis
double logb(double x);
Description
logb computes the base-FLT_RADIX logarithm of x.
543
logbf
Synopsis
float logbf(float x);
Description
logbf computes the base-FLT_RADIX logarithm of x.
544
logf
Synopsis
float logf(float x);
Description
logf computes the base-e logarithm of x.
If x = 0, errno is set to ERANGE and logf returns HUGE_VALF. If x < 0, errno is set to EDOM and logf returns
HUGE_VALF.
If x < 0 or x = , logf returns NaN.
If x = 0, logf returns .
If x = , logf returns .
If x = NaN, logf returns x.
545
lrint
Synopsis
long int lrint(double x);
Description
lrint rounds x to an integral value and returns it as a long int.
546
lrintf
Synopsis
long int lrintf(float x);
Description
lrintf rounds x to an integral value and returns it as a long int.
547
lround
Synopsis
long int lround(double x);
Description
lround rounds x to an integral value, with halfway cases rounded away from zero, and returns it as a long int.
548
lroundf
Synopsis
long int lroundf(float x);
Description
lroundf rounds x to an integral value, with halfway cases rounded away from zero, and returns it as a long int.
549
modf
Synopsis
double modf(double x,
double *iptr);
Description
modf breaks x into integral and fractional parts, each of which has the same type and sign as x.
The integral part (in floating-point format) is stored in the object pointed to by iptr and modf returns the signed
fractional part of x.
550
modff
Synopsis
float modff(float x,
float *iptr);
Description
modff breaks x into integral and fractional parts, each of which has the same type and sign as x.
The integral part (in floating-point format) is stored in the object pointed to by iptr and modff returns the signed
fractional part of x.
551
nearbyint
Synopsis
double nearbyint(double);
Description
nearbyint Rounds x to an integral value.
552
nearbyintf
Synopsis
float nearbyintf(float);
Description
nearbyintf Rounds x to an integral value.
553
nextafter
Synopsis
double nextafter(double x,
double y);
Description
nextafter Returns the next representable value after x in the direction of y.
554
nextafterf
Synopsis
float nextafterf(float x,
float y);
Description
nextafterf Returns the next representable value after x in the direction of y.
555
pow
Synopsis
double pow(double x,
double y);
Description
pow computes x raised to the power y.
If x < 0 and y 0, errno is set to EDOM and pow returns HUGE_VAL. If x 0 and y is not an integer value, errno
is set to EDOM and pow returns HUGE_VAL.
If y = 0, pow returns 1.
If y = 1, pow returns x.
If y = NaN, pow returns NaN.
If x = NaN and y is anything other than 0, pow returns NaN.
If x < 1 or 1 < x, and y = +, pow returns +.
If x < 1 or 1 < x, and y = , pow returns 0.
If 1 < x < 1 and y = +, pow returns +0.
If 1 < x < 1 and y = , pow returns +.
If x = +1 or x = 1 and y = + or y = , pow returns NaN.
If x = +0 and y > 0 and y NaN, pow returns +0.
If x = 0 and y > 0 and y NaN or y not an odd integer, pow returns +0.
If x = +0 and y and y NaN, pow returns +.
If x = 0 and y > 0 and y NaN or y not an odd integer, pow returns +.
If x = 0 and y is an odd integer, pow returns 0.
If x = + and y > 0 and y NaN, pow returns +.
If x = + and y < 0 and y NaN, pow returns +0.
If x = , pow returns pow(0, y)
If x < 0 and x and y is a non-integer, pow returns NaN.
556
powf
Synopsis
float powf(float x,
float y);
Description
powf computes x raised to the power y.
If x < 0 and y 0, errno. is set to EDOM and powf returns HUGE_VALF. If x 0 and y is not an integer value,
errno is set to EDOM and pow returns HUGE_VALF.
If y = 0, powf returns 1.
If y = 1, powf returns x.
If y = NaN, powf returns NaN.
If x = NaN and y is anything other than 0, powf returns NaN.
If x < 1 or 1 < x, and y = +, powf returns +.
If x < 1 or 1 < x, and y = , powf returns 0.
If 1 < x < 1 and y = +, powf returns +0.
If 1 < x < 1 and y = , powf returns +.
If x = +1 or x = 1 and y = + or y = , powf returns NaN.
If x = +0 and y > 0 and y NaN, powf returns +0.
If x = 0 and y > 0 and y NaN or y not an odd integer, powf returns +0.
If x = +0 and y and y NaN, powf returns +.
If x = 0 and y > 0 and y NaN or y not an odd integer, powf returns +.
If x = 0 and y is an odd integer, powf returns 0.
If x = + and y > 0 and y NaN, powf returns +.
If x = + and y < 0 and y NaN, powf returns +0.
If x = , powf returns powf(0, y)
If x < 0 and x and y is a non-integer, powf returns NaN.
557
remainder
Synopsis
double remainder(double numer,
double denom);
Description
remainder computes the remainder of numer divided by denom.
558
remainderf
Synopsis
float remainderf(float numer,
float denom);
Description
remainderf computes the remainder of numer divided by denom.
559
remquo
Synopsis
double remquo(double numer,
double denom,
int *quot);
Description
remquo computes the remainder of numer divided by denom and the quotient pointed by quot.
560
remquof
Synopsis
float remquof(float numer,
float denom,
int *quot);
Description
remquof computes the remainder of numer divided by denom and the quotient pointed by quot.
561
rint
Synopsis
double rint(double x);
Description
rint rounds x to an integral value.
562
rintf
Synopsis
float rintf(float x);
Description
rintf rounds x to an integral value.
563
round
Synopsis
double round(double x);
Description
round rounds x to an integral value, with halfway cases rounded away from zero.
564
roundf
Synopsis
float roundf(float x);
Description
roundf rounds x to an integral value, with halfway cases rounded away from zero.
565
scalbln
Synopsis
double scalbln(double x,
long int exp);
Description
scalbln multiplies x by FLT_RADIX raised to the power exp.
566
scalblnf
Synopsis
float scalblnf(float x,
long int exp);
Description
scalblnf multiplies x by FLT_RADIX raised to the power exp.
567
scalbn
Synopsis
double scalbn(double x,
int exp);
Description
scalbn multiplies a floating-point number by an integral power of DBL_RADIX.
As floating-point arithmetic conforms to IEC 60559, DBL_RADIX is 2 and scalbn is (in this implementation)
identical to ldexp.
scalbn returns x * DBL_RADIX^exp.
If the result overflows, errno is set to ERANGE and scalbn returns HUGE_VAL.
If x is or NaN, scalbn returns x.
If the result overflows, scalbn returns .
See Also
ldexp
568
scalbnf
Synopsis
float scalbnf(float x,
int exp);
Description
scalbnf multiplies a floating-point number by an integral power of FLT_RADIX.
As floating-point arithmetic conforms to IEC 60559, FLT_RADIX is 2 and scalbnf is (in this implementation)
identical to ldexpf.
scalbnf returns x * FLT_RADIX ^exp.
If the result overflows, errno is set to ERANGE and scalbnf returns HUGE_VALF.
If x is or NaN, scalbnf returns x. If the result overflows, scalbnf returns .
See Also
ldexpf
569
signbit
Synopsis
#define signbit(x) (sizeof(x) == sizeof(float) ? __float32_signbit(x) : __float64_signbit(x))
Description
signbit macro determines whether the sign of x is negative. signbit returns a non-zero value if and only if x is
negative.
570
sin
Synopsis
double sin(double x);
Description
sin returns the radian circular sine of x.
If |x| > 10^9, errno is set to EDOM and sin returns HUGE_VAL.
sin returns x if x is NaN. sin returns NaN if |x| is .
571
sinf
Synopsis
float sinf(float x);
Description
sinf returns the radian circular sine of x.
If |x| > 10^9, errno is set to EDOM and sinf returns HUGE_VALF.
sinf returns x if x is NaN. sinf returns NaN if |x| is .
572
sinh
Synopsis
double sinh(double x);
Description
sinh calculates the hyperbolic sine of x.
If |x| .782, errno is set to EDOM and sinh returns HUGE_VAL.
If x is +, , or NaN, sinh returns |x|. If |x| > ~709.782, sinh returns + or depending upon the sign of x.
573
sinhf
Synopsis
float sinhf(float x);
Description
sinhf calculates the hyperbolic sine of x.
If |x| > ~88.7228, errno is set to EDOM and sinhf returns HUGE_VALF.
If x is +, , or NaN, sinhf returns |x|. If |x| > ~88.7228, sinhf returns + or depending upon the sign of x.
574
sqrt
Synopsis
double sqrt(double x);
Description
sqrt computes the nonnegative square root of x. C90 and C99 require that a domain error occurs if the argument
is less than zero sqrt deviates and always uses IEC 60559 semantics.
If x is +0, sqrt returns +0.
If x is 0, sqrt returns 0.
If x is , sqrt returns .
If x < 0, sqrt returns NaN.
If x is NaN, sqrt returns that NaN.
575
sqrtf
Synopsis
float sqrtf(float x);
Description
sqrtf computes the nonnegative square root of x. C90 and C99 require that a domain error occurs if the
argument is less than zero sqrtf deviates and always uses IEC 60559 semantics.
If x is +0, sqrtf returns +0.
If x is 0, sqrtf returns 0.
If x is , sqrtf returns .
If x < 0, sqrtf returns NaN.
If x is NaN, sqrtf returns that NaN.
576
tan
Synopsis
double tan(double x);
Description
tan returns the radian circular tangent of x.
If |x| > 10^9, errno is set to EDOM and tan returns HUGE_VAL.
If x is NaN, tan returns x. If |x| is , tan returns NaN.
577
tanf
Synopsis
float tanf(float x);
Description
tanf returns the radian circular tangent of x.
If |x| > 10^9, errno is set to EDOM and tanf returns HUGE_VALF.
If x is NaN, tanf returns x. If |x| is , tanf returns NaN.
578
tanh
Synopsis
double tanh(double x);
Description
tanh calculates the hyperbolic tangent of x.
If x is NaN, tanh returns NaN.
579
tanhf
Synopsis
float tanhf(float x);
Description
tanhf calculates the hyperbolic tangent of x.
If x is NaN, tanhf returns NaN.
580
tgamma
Synopsis
double tgamma(double x);
Description
tgamma returns the gamma function for x.
581
tgammaf
Synopsis
float tgammaf(float x);
Description
tgammaf returns the gamma function for x.
582
trunc
Synopsis
double trunc(double x);
Description
trunc rounds x to an integral value that is not larger in magnitude than x.
583
truncf
Synopsis
float truncf(float x);
Description
truncf rounds x to an integral value that is not larger in magnitude than x.
584
<setjmp.h>
API Summary
Functions
longjmp
setjmp
585
longjmp
Synopsis
void longjmp(jmp_buf env,
int val);
Description
longjmp restores the environment saved by setjmp in the corresponding env argument. If there has been no
such invocation, or if the function containing the invocation of setjmp has terminated execution in the interim,
the behavior of longjmp is undefined.
After longjmp is completed, program execution continues as if the corresponding invocation of setjmp had just
returned the value specified by val.
Note
longjmp cannot cause setjmp to return the value 0; if val is 0, setjmp returns the value 1.
Objects of automatic storage allocation that are local to the function containing the invocation of the
corresponding setjmp that do not have volatile qualified type and have been changed between the setjmp
invocation and this call are indeterminate.
586
setjmp
Synopsis
int setjmp(jmp_buf env);
Description
setjmp saves its calling environment in the env for later use by the longjmp function.
On return from a direct invocation setjmp returns the value zero. On return from a call to the longjmp function,
the setjmp returns a nonzero value determined by the call to longjmp.
The environment saved by a call to setjmp consists of information sufficient for a call to the longjmp function to
return execution to the correct block and invocation of that block, were it called recursively.
587
<stdarg.h>
API Summary
Macros
va_arg
va_copy
va_end
va_start
588
va_arg
Synopsis
type va_arg(va_list ap,
type);
Description
va_arg expands to an expression that has the specified type and the value of the type argument. The ap
parameter must have been initialized by va_start or va_copy, without an intervening invocation of va_end. You
can create a pointer to a va_list and pass that pointer to another function, in which case the original function
may make further use of the original list after the other function returns.
Each invocation of the va_arg macro modifies ap so that the values of successive arguments are returned in
turn. The parameter type must be a type name such that the type of a pointer to an object that has the specified
type can be obtained simply by postfixing a * to type.
If there is no actual next argument, or if type is not compatible with the type of the actual next argument (as
promoted according to the default argument promotions), the behavior of va_arg is undefined, except for the
following cases:
one type is a signed integer type, the other type is the corresponding unsigned integer type, and the
value is representable in both types;
one type is pointer to void and the other is a pointer to a character type.
The first invocation of the va_arg macro after that of the va_start macro returns the value of the argument after
that specified by parmN. Successive invocations return the values of the remaining arguments in succession.
589
va_copy
Synopsis
void va_copy(va_list dest,
val_list src);
Description
va_copy initializes dest as a copy of src, as if the va_start macro had been applied to dest followed by the same
sequence of uses of the va_arg macro as had previously been used to reach the present state of src. Neither
the va_copy nor va_start macro shall be invoked to reinitialize dest without an intervening invocation of the
va_end macro for the same dest.
590
va_end
Synopsis
void va_end(va_list ap);
Description
va_end indicates a normal return from the function whose variable argument list ap was initialised by va_start
or va_copy. The va_end macro may modify ap so that it is no longer usable without being reinitialized by
va_start or va_copy. If there is no corresponding invocation of va_start or va_copy, or if va_end is not invoked
before the return, the behavior is undefined.
591
va_start
Synopsis
void va_start(va_list ap,
paramN);
Description
va_start initializes ap for subsequent use by the va_arg and va_end macros.
The parameter parmN is the identifier of the last fixed parameter in the variable parameter list in the function
definition (the one just before the ', ...').
The behaviour of va_start and va_arg is undefined if the parameter parmN is declared with the register
storage class, with a function or array type, or with a type that is not compatible with the type that results after
application of the default argument promotions.
va_start must be invoked before any access to the unnamed arguments.
va_start and va_copy must not be invoked to reinitialize ap without an intervening invocation of the va_end
macro for the same ap.
592
<stddef.h>
API Summary
Macros
NULL
NULL pointer
offsetof
offsetof
Types
ptrdiff_t
ptrdiff_t type
size_t
size_t type
593
NULL
Synopsis
#define NULL 0
Description
NULL is the null pointer constant.
594
offsetof
Synopsis
#define offsetof(type, member)
Description
offsetof returns the offset in bytes to the structure member, from the beginning of its structure type.
595
ptrdiff_t
Synopsis
typedef __RAL_PTRDIFF_T ptrdiff_t;
Description
ptrdiff_t is the signed integral type of the result of subtracting two pointers.
596
size_t
Synopsis
typedef __RAL_SIZE_T size_t;
Description
size_t is the unsigned integral type returned by the sizeof operator.
597
<stdio.h>
API Summary
Character and string I/O functions
getchar
gets
putchar
puts
snprintf
sprintf
vprintf
vsnprintf
vsprintf
sscanf
vscanf
vsscanf
598
getchar
Synopsis
int getchar(void);
Description
getchar reads a single character from the standard input stream.
If the stream is at end-of-file or a read error occurs, getchar returns EOF.
599
gets
Synopsis
char *gets(char *s);
Description
gets reads characters from standard input into the array pointed to by s until end-of-file is encountered or a
new-line character is read. Any new-line character is discarded, and a null character is written immediately after
the last character read into the array.
gets returns s if successful. If end-of-file is encountered and no characters have been read into the array, the
contents of the array remain unchanged and gets returns a null pointer. If a read error occurs during the
operation, the array contents are indeterminate and gets returns a null pointer.
600
printf
Synopsis
int printf(const char *format,
...);
Description
printf writes to the standard output stream using putchar, under control of the string pointed to by format that
specifies how subsequent arguments are converted for output.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
printf returns the number of characters transmitted, or a negative value if an output or encoding error occurred.
601
Some library variants do not support width and precision specifiers in order to reduce code and data space
requirements; please ensure that you have selected the correct library in the Printf Width/Precision Support
property of the project if you use these.
Flag characters
The flag characters and their meanings are:
-
The result of the conversion is left-justified within the field. The default, if this flag is not specified, is that the
result of the conversion is left-justified within the field.
+
The result of a signed conversion always begins with a plus or minus sign. The default, if this flag is not
specified, is that it begins with a sign only when a negative value is converted.
space
If the first character of a signed conversion is not a sign, or if a signed conversion results in no characters, a
space is prefixed to the result. If the space and + flags both appear, the space flag is ignored.
#
The result is converted to an alternative form. For o conversion, it increases the precision, if and only if
necessary, to force the first digit of the result to be a zero (if the value and precision are both zero, a single
0 is printed). For x or X conversion, a nonzero result has 0x or 0X prefixed to it. For e, E, f, F, g, and
G conversions, the result of converting a floating-point number always contains a decimal-point character,
even if no digits follow it. (Normally, a decimal-point character appears in the result of these conversions
only if a digit follows it.) For g and F conversions, trailing zeros are not removed from the result. As an
extension, when used in p conversion, the results has # prefixed to it. For other conversions, the behavior
is undefined.
0
For d, i, o, u, x, X, e, E, f, F, g, and G conversions, leading zeros (following any indication of
sign or base) are used to pad to the field width rather than performing space padding, except when
converting an infinity or NaN. If the 0 and - flags both appear, the 0 flag is ignored. For d, i, o, u, x,
and X conversions, if a precision is specified, the 0 flag is ignored. For other conversions, the behavior is
undefined.
Length modifiers
The length modifiers and their meanings are:
hh
Specifies that a following d, i, o, u, x, or X conversion specifier applies to a signed char or unsigned
char argument (the argument will have been promoted according to the integer promotions, but its value
will be converted to signed char or unsigned char before printing); or that a following n conversion
specifier applies to a pointer to a signed char argument.
602
h
Specifies that a following d, i, o, u, x, or X conversion specifier applies to a short int or unsigned short
int argument (the argument will have been promoted according to the integer promotions, but its value
is converted to short int or unsigned short int before printing); or that a following n conversion specifier
applies to a pointer to a short int argument.
l
Specifies that a following d, i, o, u, x, or X conversion specifier applies to a long int or unsigned long
int argument; that a following n conversion specifier applies to a pointer to a long int argument; or has no
effect on a following e, E, f, F, g, or G conversion specifier. Some library variants do not support the l
length modifier in order to reduce code and data space requirements; please ensure that you have selected
the correct library in the Printf Integer Support property of the project if you use this length modifier.
ll
Specifies that a following d, i, o, u, x, or X conversion specifier applies to a long long int or unsigned
long long int argument; that a following n conversion specifier applies to a pointer to a long long int
argument. Some library variants do not support the ll length modifier in order to reduce code and data
space requirements; please ensure that you have selected the correct library in the Printf Integer Support
property of the project if you use this length modifier.
If a length modifier appears with any conversion specifier other than as specified above, the behavior is
undefined. Note that the C99 length modifiers j, z, t, and L are not supported.
Conversion specifiers
The conversion specifiers and their meanings are:
d, i
The argument is converted to signed decimal in the style [-]dddd. The precision specifies the minimum
number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded
with leading spaces. The default precision is one. The result of converting a zero value with a precision of
zero is no characters.
o, u, x, X
The unsigned argument is converted to unsigned octal for o, unsigned decimal for u, or unsigned
hexadecimal notation for x or X in the style dddd the letters abcdef are used for x conversion and the
letters ABCDEF for X conversion. The precision specifies the minimum number of digits to appear; if the
value being converted can be represented in fewer digits, it is expanded with leading spaces. The default
precision is one. The result of converting a zero value with a precision of zero is no characters.
f, F
A double argument representing a floating-point number is converted to decimal notation in the
style [-]ddd.ddd, where the number of digits after the decimal-point character is equal to the precision
specification. If the precision is missing, it is taken as 6; if the precision is zero and the # flag is not specified,
603
no decimal-point character appears. If a decimal-point character appears, at least one digit appears before
it. The value is rounded to the appropriate number of digits. A double argument representing an infinity is
converted to inf. A double argument representing a NaN is converted to nan. The F conversion specifier
produces INF or NAN instead of inf or nan, respectively. Some library variants do not support the f and
F conversion specifiers in order to reduce code and data space requirements; please ensure that you have
selected the correct library in the Printf Floating Point Support property of the project if you use these
conversion specifiers.
e, E
A double argument representing a floating-point number is converted in the style [-]d.dddedd, where
there is one digit (which is nonzero if the argument is nonzero) before the decimal-point character and
the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6; if the
precision is zero and the # flag is not specified, no decimal-point character appears. The value is rounded
to the appropriate number of digits. The E conversion specifier produces a number with E instead
of e introducing the exponent. The exponent always contains at least two digits, and only as many
more digits as necessary to represent the exponent. If the value is zero, the exponent is zero. A double
argument representing an infinity is converted to inf. A double argument representing a NaN is converted
to nan. The E conversion specifier produces INF or NAN instead of inf or nan, respectively. Some
library variants do not support the f and F conversion specifiers in order to reduce code and data space
requirements; please ensure that you have selected the correct library in the Printf Floating Point Support}
property of the project if you use these conversion specifiers.
g, G
A double argument representing a floating-point number is converted in style f or e (or in style F or e
in the case of a G conversion specifier), with the precision specifying the number of significant digits. If
the precision is zero, it is taken as one. The style used depends on the value converted; style e (or E) is
used only if the exponent resulting from such a conversion is less than -4 or greater than or equal to the
precision. Trailing zeros are removed from the fractional portion of the result unless the # flag is specified;
a decimal-point character appears only if it is followed by a digit. A double argument representing an
infinity is converted to inf. A double argument representing a NaN is converted to nan. The G conversion
specifier produces INF or NAN instead of inf or nan, respectively. Some library variants do not support
the f and F conversion specifiers in order to reduce code and data space requirements; please ensure that
you have selected the correct library in the Printf Floating Point Support property of the project if you use
these conversion specifiers.
c
The argument is converted to an unsigned char, and the resulting character is written.
s
The argument is be a pointer to the initial element of an array of character type. Characters from the array
are written up to (but not including) the terminating null character. If the precision is specified, no more
than that many characters are written. If the precision is not specified or is greater than the size of the array,
the array must contain a null character.
604
p
The argument is a pointer to void. The value of the pointer is converted in the same format as the x
conversion specifier with a fixed precision of 2*sizeof(void *).
n
The argument is a pointer to a signed integer into which is written the number of characters written to the
output stream so far by the call to the formatting function. No argument is converted, but one is consumed.
If the conversion specification includes any flags, a field width, or a precision, the behavior is undefined.
%
A % character is written. No argument is converted.
Note that the C99 width modifier l used in conjunction with the c and s conversion specifiers is not supported
and nor are the conversion specifiers a and A.
605
putchar
Synopsis
int putchar(int c);
Description
putchar writes the character c to the standard output stream.
putchar returns the character written. If a write error occurs, putchar returns EOF.
606
puts
Synopsis
int puts(const char *s);
Description
puts writes the string pointed to by s to the standard output stream using putchar and appends a new-line
character to the output. The terminating null character is not written.
puts returns EOF if a write error occurs; otherwise it returns a nonnegative value.
607
scanf
Synopsis
int scanf(const char *format,
...);
Description
scanf reads input from the standard input stream under control of the string pointed to by format that specifies
the admissible input sequences and how they are to be converted for assignment, using subsequent arguments
as pointers to the objects to receive the converted input.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
scanf returns the value of the macro EOF if an input failure occurs before any conversion. Otherwise, scanf
returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of
an early matching failure.
608
Input white-space characters (as specified by the isspace function) are skipped, unless the specification
includes a [, c, or n specifier.
An input item is read from the stream, unless the specification includes an n specifier. An input item is
defined as the longest sequence of input characters which does not exceed any specified field width
and which is, or is a prefix of, a matching input sequence. The first character, if any, after the input item
remains unread. If the length of the input item is zero, the execution of the directive fails; this condition is
a matching failure unless end-of-file, an encoding error, or a read error prevented input from the stream,
in which case it is an input failure.
Except in the case of a % specifier, the input item (or, in the case of a %n directive, the count of input
characters) is converted to a type appropriate to the conversion specifier. If the input item is not a
matching sequence, the execution of the directive fails: this condition is a matching failure. Unless
assignment suppression was indicated by a *, the result of the conversion is placed in the object pointed
to by the first argument following the format argument that has not already received a conversion result.
If this object does not have an appropriate type, or if the result of the conversion cannot be represented
in the object, the behavior is undefined.
Length modifiers
The length modifiers and their meanings are:
hh
Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type
pointer to signed char or pointer to unsigned char.
h
Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type
pointer to short int or unsigned short int.
l
Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type
pointer to long int or unsigned long int; that a following e, E, f, F, g, or G conversion specifier applies
to an argument with type pointer to double. Some library variants do not support the l length modifier in
order to reduce code and data space requirements; please ensure that you have selected the correct library
in the Printf Integer Support property of the project if you use this length modifier.
ll
Specifies that a following d, i, o, u, x, X, or n conversion specifier applies to an argument with type
pointer to long long int or unsigned long long int. Some library variants do not support the ll length
modifier in order to reduce code and data space requirements; please ensure that you have selected the
correct library in the Printf Integer Support property of the project if you use this length modifier.
If a length modifier appears with any conversion specifier other than as specified above, the behavior is
undefined. Note that the C99 length modifiers j, z, t, and L are not supported.
609
Conversion specifiers
d
Matches an optionally signed decimal integer, whose format is the same as expected for the subject
sequence of the strtol function with the value 10 for the base argument. The corresponding argument
must be a pointer to signed integer.
i
Matches an optionally signed integer, whose format is the same as expected for the subject sequence of the
strtol function with the value zero for the base argument. The corresponding argument must be a pointer
to signed integer.
o
Matches an optionally signed octal integer, whose format is the same as expected for the subject sequence
of the strtol function with the value 18 for the base argument. The corresponding argument must be a
pointer to signed integer.
u
Matches an optionally signed decimal integer, whose format is the same as expected for the subject
sequence of the strtoul function with the value 10 for the base argument. The corresponding argument
must be a pointer to unsigned integer.
x
Matches an optionally signed hexadecimal integer, whose format is the same as expected for the subject
sequence of the strtoul function with the value 16 for the base argument. The corresponding argument
must be a pointer to unsigned integer.
e, f, g
Matches an optionally signed floating-point number whose format is the same as expected for the subject
sequence of the strtod function. The corresponding argument shall be a pointer to floating. Some library
variants do not support the e, f and F conversion specifiers in order to reduce code and data space
requirements; please ensure that you have selected the correct library in the Scanf Floating Point Support
property of the project if you use these conversion specifiers.
c
Matches a sequence of characters of exactly the number specified by the field width (one if no field width
is present in the directive). The corresponding argument must be a pointer to the initial element of a
character array large enough to accept the sequence. No null character is added.
s
Matches a sequence of non-white-space characters The corresponding argument must be a pointer to the
initial element of a character array large enough to accept the sequence and a terminating null character,
which will be added automatically.
610
[
Matches a nonempty sequence of characters from a set of expected characters (the scanset). The
corresponding argument must be a pointer to the initial element of a character array large enough to
accept the sequence and a terminating null character, which will be added automatically. The conversion
specifier includes all subsequent characters in the format string, up to and including the matching right
bracket ]. The characters between the brackets (the scanlist) compose the scanset, unless the character
after the left bracket is a circumflex ^, in which case the scanset contains all characters that do not appear
in the scanlist between the circumflex and the right bracket. If the conversion specifier begins with []
or[^], the right bracket character is in the scanlist and the next following right bracket character is the
matching right bracket that ends the specification; otherwise the first following right bracket character
is the one that ends the specification. If a - character is in the scanlist and is not the first, nor the second
where the first character is a ^, nor the last character, it is treated as a member of the scanset. Some library
variants do not support the [ conversion specifier in order to reduce code and data space requirements;
please ensure that you have selected the correct library in the Scanf Classes Supported property of the
project if you use this conversion specifier.
p
Reads a sequence output by the corresponding %p formatted output conversion. The corresponding
argument must be a pointer to a pointer to void.
n
No input is consumed. The corresponding argument shall be a pointer to signed integer into which is to
be written the number of characters read from the input stream so far by this call to the formatted input
function. Execution of a %n directive does not increment the assignment count returned at the completion
of execution of the fscanf function. No argument is converted, but one is consumed. If the conversion
specification includes an assignment-suppressing character or a field width, the behavior is undefined.
%
Matches a single % character; no conversion or assignment occurs.
Note that the C99 width modifier l used in conjunction with the c, s, and [ conversion specifiers is not
supported and nor are the conversion specifiers a and A.
611
snprintf
Synopsis
int snprintf(char *s,
size_t n,
const char *format,
...);
Description
snprintf writes to the string pointed to by s under control of the string pointed to by format that specifies how
subsequent arguments are converted for output.
If n is zero, nothing is written, and s can be a null pointer. Otherwise, output characters beyond the n1st are
discarded rather than being written to the array, and a null character is written at the end of the characters
actually written into the array. A null character is written at the end of the conversion; it is not counted as part of
the returned value.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
If copying takes place between objects that overlap, the behavior is undefined.
snprintf returns the number of characters that would have been written had n been sufficiently large, not
counting the terminating null character, or a negative value if an encoding error occurred. Thus, the nullterminated output has been completely written if and only if the returned value is nonnegative and less than n>.
612
sprintf
Synopsis
int sprintf(char *s,
const char *format,
...);
Description
sprintf writes to the string pointed to by s under control of the string pointed to by format that specifies how
subsequent arguments are converted for output. A null character is written at the end of the characters written;
it is not counted as part of the returned value.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
If copying takes place between objects that overlap, the behavior is undefined.
sprintf returns number of characters transmitted (not counting the terminating null), or a negative value if an
output or encoding error occurred.
613
sscanf
Synopsis
int sscanf(const char *s,
const char *format,
...);
Description
sscanf reads input from the string s under control of the string pointed to by format that specifies the
admissible input sequences and how they are to be converted for assignment, using subsequent arguments as
pointers to the objects to receive the converted input.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
sscanf returns the value of the macro EOF if an input failure occurs before any conversion. Otherwise, sscanf
returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of
an early matching failure.
614
vprintf
Synopsis
int vprintf(const char *format,
__va_list arg);
Description
vprintf writes to the standard output stream using putchar under control of the string pointed to by format that
specifies how subsequent arguments are converted for output. Before calling vprintf, arg must be initialized by
the va_start macro (and possibly subsequent va_arg calls). vprintf does not invoke the va_end macro.
vprintf returns the number of characters transmitted, or a negative value if an output or encoding error
occurred.
Note
vprintf is equivalent to printf with the variable argument list replaced by arg.
615
vscanf
Synopsis
int vscanf(const char *format,
__va_list arg);
Description
vscanf reads input from the standard input stream under control of the string pointed to by format that
specifies the admissible input sequences and how they are to be converted for assignment, using subsequent
arguments as pointers to the objects to receive the converted input. Before calling vscanf, arg must be
initialized by the va_start macro (and possibly subsequent va_arg calls). vscanf does not invoke the va_end
macro.
If there are insufficient arguments for the format, the behavior is undefined.
vscanf returns the value of the macro EOF if an input failure occurs before any conversion. Otherwise, vscanf
returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of
an early matching failure.
Note
vscanf is equivalent to scanf with the variable argument list replaced arg.
616
vsnprintf
Synopsis
int vsnprintf(char *s,
size_t n,
const char *format,
__va_list arg);
Description
vsnprintf writes to the string pointed to by s under control of the string pointed to by format that specifies how
subsequent arguments are converted for output. Before calling vsnprintf, arg must be initialized by the va_start
macro (and possibly subsequent va_arg calls). vsnprintf does not invoke the va_end macro.
If n is zero, nothing is written, and s can be a null pointer. Otherwise, output characters beyond the n1st are
discarded rather than being written to the array, and a null character is written at the end of the characters
actually written into the array. A null character is written at the end of the conversion; it is not counted as part of
the returned value.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
If copying takes place between objects that overlap, the behavior is undefined.
vsnprintf returns the number of characters that would have been written had n been sufficiently large, not
counting the terminating null character, or a negative value if an encoding error occurred. Thus, the nullterminated output has been completely written if and only if the returned value is nonnegative and less than n.
Note
vsnprintf is equivalent to snprintf with the variable argument list replaced by arg.
617
vsprintf
Synopsis
int vsprintf(char *s,
const char *format,
__va_list arg);
Description
vsprintf writes to the string pointed to by s under control of the string pointed to by format that specifies how
subsequent arguments are converted for output. Before calling vsprintf, arg must be initialized by the va_start
macro (and possibly subsequent va_arg calls). vsprintf does not invoke the va_end macro.
A null character is written at the end of the characters written; it is not counted as part of the returned value.
If there are insufficient arguments for the format, the behavior is undefined. If the format is exhausted while
arguments remain, the excess arguments are evaluated but are otherwise ignored.
If copying takes place between objects that overlap, the behavior is undefined.
vsprintf returns number of characters transmitted (not counting the terminating null), or a negative value if an
output or encoding error occurred.
Note
vsprintf is equivalent to sprintf with the variable argument list replaced by arg.
618
vsscanf
Synopsis
int vsscanf(const char *s,
const char *format,
__va_list arg);
Description
vsscanf reads input from the string s under control of the string pointed to by format that specifies the
admissible input sequences and how they are to be converted for assignment, using subsequent arguments
as pointers to the objects to receive the converted input. Before calling vsscanf, arg must be initialized by the
va_start macro (and possibly subsequent va_arg calls). vsscanf does not invoke the va_end macro.
If there are insufficient arguments for the format, the behavior is undefined.
vsscanf returns the value of the macro EOF if an input failure occurs before any conversion. Otherwise, vsscanf
returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of
an early matching failure.
Note
vsscanf is equivalent to sscanf with the variable argument list replaced by arg.
619
<stdlib.h>
API Summary
Macros
EXIT_FAILURE
EXIT_FAILURE
EXIT_SUCCESS
EXIT_SUCCESS
MB_CUR_MAX
RAND_MAX
RAND_MAX
Types
div_t
ldiv_t
lldiv_t
div
labs
ldiv
llabs
lldiv
free
malloc
realloc
atoi
atol
atoll
620
strtod
strtof
strtol
strtoll
strtoul
strtoull
srand
qsort
Sort an array
Environment
atexit
exit
lltoa
ltoa
ulltoa
ultoa
utoa
mblen_l
mbstowcs_l
mbtowc
mbtowc_l
621
EXIT_FAILURE
Synopsis
#define EXIT_FAILURE
Description
EXIT_FAILURE pass to exit on unsuccessful termination.
622
EXIT_SUCCESS
Synopsis
#define EXIT_SUCCESS
Description
EXIT_SUCCESS pass to exit on successful termination.
623
MB_CUR_MAX
Synopsis
#define MB_CUR_MAX
__RAL_mb_max(&__RAL_global_locale)
Description
MB_CUR_MAX expands to a positive integer expression with type size_t that is the maximum number of bytes
in a multi-byte character for the extended character set specified by the current locale (category LC_CTYPE).
MB_CUR_MAX is never greater than MB_LEN_MAX.
624
RAND_MAX
Synopsis
#define RAND_MAX 32767
Description
RAND_MAX expands to an integer constant expression that is the maximum value returned by rand.
625
abs
Synopsis
int abs(int j);
Description
abs returns the absolute value of the integer argument j.
626
atexit
Synopsis
int atexit(void (*func)(void));
Description
atexit registers function to be called when the application has exited. The functions registered with atexit are
executed in reverse order of their registration. atexit returns 0 on success and non-zero on failure.
627
atof
Synopsis
double atof(const char *nptr);
Description
atof converts the initial portion of the string pointed to by nptr to a double representation.
atof does not affect the value of errno on an error. If the value of the result cannot be represented, the behavior
is undefined.
Except for the behavior on error, atof is equivalent to strtod(nptr, (char **)NULL).
atof returns the converted value.
See Also
strtod
628
atoi
Synopsis
int atoi(const char *nptr);
Description
atoi converts the initial portion of the string pointed to by nptr to an int representation.
atoi does not affect the value of errno on an error. If the value of the result cannot be represented, the behavior
is undefined.
Except for the behavior on error, atoi is equivalent to (int)strtol(nptr, (char **)NULL, 10).
atoi returns the converted value.
See Also
strtol
629
atol
Synopsis
long int atol(const char *nptr);
Description
atol converts the initial portion of the string pointed to by nptr to a long int representation.
atol does not affect the value of errno on an error. If the value of the result cannot be represented, the behavior
is undefined.
Except for the behavior on error, atol is equivalent to strtol(nptr, (char **)NULL, 10).
atol returns the converted value.
See Also
strtol
630
atoll
Synopsis
long long int atoll(const char *nptr);
Description
atoll converts the initial portion of the string pointed to by nptr to a long long int representation.
atoll does not affect the value of errno on an error. If the value of the result cannot be represented, the behavior
is undefined.
Except for the behavior on error, atoll is equivalent to strtoll(nptr, (char **)NULL, 10).
atoll returns the converted value.
See Also
strtoll
631
bsearch
Synopsis
void *bsearch(const void *key,
const void *buf,
size_t num,
size_t size,
int (*compare)(const void *, const void *));
Description
bsearch searches the array *base for the specified *key and returns a pointer to the first entry that matches or
null if no match. The array should have num elements of size bytes and be sorted by the same algorithm as the
compare function.
The compare function should return a negative value if the first parameter is less than second parameter, zero if
the parameters are equal, and a positive value if the first parameter is greater than the second parameter.
632
calloc
Synopsis
void *calloc(size_t nobj,
size_t size);
Description
calloc allocates space for an array of nmemb objects, each of whose size is size. The space is initialized to all zero
bits.
calloc returns a null pointer if the space for the array of object cannot be allocated from free memory; if space for
the array can be allocated, calloc returns a pointer to the start of the allocated space.
633
div
Synopsis
div_t div(int numer,
int denom);
Description
div computes numer / denom and numer % denom in a single operation.
div returns a structure of type div_t comprising both the quotient and the remainder. The structures contain
the members quot (the quotient) and rem (the remainder), each of which has the same type as the arguments
numer and denom. If either part of the result cannot be represented, the behavior is undefined.
See Also
div_t
634
div_t
Description
div_t stores the quotient and remainder returned by div.
635
exit
Synopsis
void exit(int exit_code);
Description
exit returns to the startup code and performs the appropriate cleanup process.
636
free
Synopsis
void free(void *p);
Description
free causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a
null pointer, no action occurs.
If ptr does not match a pointer earlier returned by calloc, malloc, or realloc, or if the space has been deallocated
by a call to free or realloc, the behavior is undefined.
637
itoa
Synopsis
char *itoa(int val,
char *buf,
int radix);
Description
itoa converts val to a string in base radix and places the result in buf.
itoa returns buf as the result.
If radix is greater than 36, the result is undefined.
If val is negative and radix is 10, the string has a leading minus sign (-); for all other values of radix, value is
considered unsigned and never has a leading minus sign.
See Also
ltoa, lltoa, ultoa, ulltoa, utoa
638
labs
Synopsis
long int labs(long int j);
Description
labs returns the absolute value of the long integer argument j.
639
ldiv
Synopsis
ldiv_t ldiv(long int numer,
long int denom);
Description
ldiv computes numer / denom and numer % denom in a single operation.
ldiv returns a structure of type ldiv_t comprising both the quotient and the remainder. The structures contain
the members quot (the quotient) and rem (the remainder), each of which has the same type as the arguments
numer and denom. If either part of the result cannot be represented, the behavior is undefined.
See Also
ldiv_t
640
ldiv_t
Description
ldiv_t stores the quotient and remainder returned by ldiv.
641
llabs
Synopsis
long long int llabs(long long int j);
Description
llabs returns the absolute value of the long long integer argument j.
642
lldiv
Synopsis
lldiv_t lldiv(long long int numer,
long long int denom);
See Also
lldiv_t
643
lldiv_t
Description
lldiv_t stores the quotient and remainder returned by lldiv.
644
lltoa
Synopsis
char *lltoa(long long val,
char *buf,
int radix);
Description
lltoa converts val to a string in base radix and places the result in buf.
lltoa returns buf as the result.
If radix is greater than 36, the result is undefined.
If val is negative and radix is 10, the string has a leading minus sign (-); for all other values of radix, value is
considered unsigned and never has a leading minus sign.
See Also
itoa, ltoa, ultoa, ulltoa, utoa
645
ltoa
Synopsis
char *ltoa(long val,
char *buf,
int radix);
Description
ltoa converts val to a string in base radix and places the result in buf.
ltoa returns buf as the result.
If radix is greater than 36, the result is undefined.
If val is negative and radix is 10, the string has a leading minus sign (-); for all other values of radix, value is
considered unsigned and never has a leading minus sign.
See Also
itoa, lltoa, ultoa, ulltoa, utoa
646
malloc
Synopsis
void *malloc(size_t size);
Description
malloc allocates space for an object whose size is specified by 'b size and whose value is indeterminate.
malloc returns a null pointer if the space for the object cannot be allocated from free memory; if space for the
object can be allocated, malloc returns a pointer to the start of the allocated space.
647
mblen
Synopsis
int mblen(const char *s,
size_t n);
Description
mblen determines the number of bytes contained in the multi-byte character pointed to by s in the current
locale.
If s is a null pointer, mblen returns a nonzero or zero value, if multi-byte character encodings, respectively, do or
do not have state-dependent encodings
If s is not a null pointer, mblen either returns 0 (if s points to the null character), or returns the number of bytes
that are contained in the multi-byte character (if the next n or fewer bytes form a valid multi-byte character), or
returns 1 (if they do not form a valid multi-byte character).
Note
Except that the conversion state of the mbtowc function is not affected, it is equivalent to
mbtowc((wchar_t *)0, s, n);
Note
It is guaranteed that no library function in the Standard C library calls mblen.
See Also
mblen_l, mbtowc
648
mblen_l
Synopsis
int mblen_l(const char *s,
size_t n,
__locale_s *loc);
Description
mblen_l determines the number of bytes contained in the multi-byte character pointed to by s in the locale loc.
If s is a null pointer, mblen_l returns a nonzero or zero value, if multi-byte character encodings, respectively, do
or do not have state-dependent encodings
If s is not a null pointer, mblen_l either returns 0 (if s points to the null character), or returns the number of bytes
that are contained in the multi-byte character (if the next n or fewer bytes form a valid multi-byte character), or
returns 1 (if they do not form a valid multi-byte character).
Note
Except that the conversion state of the mbtowc_l function is not affected, it is equivalent to
mbtowc((wchar_t *)0, s, n, loc);
Note
It is guaranteed that no library function in the Standard C library calls mblen_l.
See Also
mblen_l, mbtowc_l
649
mbstowcs
Synopsis
size_t mbstowcs(wchar_t *pwcs,
const char *s,
size_t n);
Description
mbstowcs converts a sequence of multi-byte characters that begins in the initial shift state from the array
pointed to by s into a sequence of corresponding wide characters and stores not more than n wide characters
into the array pointed to by pwcs.
No multi-byte characters that follow a null character (which is converted into a null wide character) will be
examined or converted. Each multi-byte character is converted as if by a call to the mbtowc function, except that
the conversion state of the mbtowc function is not affected.
No more than n elements will be modified in the array pointed to by pwcs. If copying takes place between
objects that overlap, the behavior is undefined.
mbstowcs returns 1 if an invalid multi-byte character is encountered, otherwise mbstowcs returns the number
of array elements modified (if any), not including a terminating null wide character.
650
mbstowcs_l
Synopsis
size_t mbstowcs_l(wchar_t *pwcs,
const char *s,
size_t n,
__locale_s *loc);
Description
mbstowcs_l is as mbstowcs except that the local loc is used for the conversion as opposed to the current locale.
See Also
mbstowcs.
651
mbtowc
Synopsis
int mbtowc(wchar_t *pwc,
const char *s,
size_t n);
Description
mbtowc converts a single multi-byte character to a wide character in the current locale.
If s is a null pointer, mbtowc returns a nonzero value if multi-byte character encodings are state-dependent in
the current locale, and zero otherwise.
If s is not null and the object that s points to is a wide-character null character, mbtowc returns 0.
If s is not null and the object that points to forms a valid multi-byte character, mbtowc returns the length in
bytes of the multi-byte character.
If the object that points to does not form a valid multi-byte character within the first n characters, it returns 1.
See Also
mbtowc_l
652
mbtowc_l
Synopsis
int mbtowc_l(wchar_t *pwc,
const char *s,
size_t n,
__locale_s *loc);
Description
mbtowc_l converts a single multi-byte character to a wide character in locale loc.
If s is a null pointer, mbtowc_l returns a nonzero value if multi-byte character encodings are state-dependent in
the locale loc, and zero otherwise.
If s is not null and the object that s points to is a wide-character null character, mbtowc_l returns 0.
If s is not null and the object that points to forms a valid multi-byte character, mbtowc_l returns the length in
bytes of the multi-byte character.
If the object that s points to does not form a valid multi-byte character within the first n characters, it returns 1.
See Also
mbtowc
653
qsort
Synopsis
void qsort(void *buf,
size_t num,
size_t size,
int (*compare)(const void *, const void *));
qsort sorts the array *base using the compare function. The array should have num elements of size bytes. The
compare function should return a negative value if the first parameter is less than second parameter, zero if the
parameters are equal and a positive value if the first parameter is greater than the second parameter.
654
rand
Synopsis
int rand(void);
Description
rand computes a sequence of pseudo-random integers in the range 0 to RAND_MAX.
rand returns the computed pseudo-random integer.
655
realloc
Synopsis
void *realloc(void *p,
size_t size);
Description
realloc deallocates the old object pointed to by ptr and returns a pointer to a new object that has the size
specified by size. The contents of the new object is identical to that of the old object prior to deallocation,
up to the lesser of the new and old sizes. Any bytes in the new object beyond the size of the old object have
indeterminate values.
If ptr is a null pointer, realloc behaves like realloc for the specified size. If memory for the new object cannot be
allocated, the old object is not deallocated and its value is unchanged.
realloc returns a pointer to the new object (which may have the same value as a pointer to the old object), or a
null pointer if the new object could not be allocated.
If ptr does not match a pointer earlier returned by calloc, malloc, or realloc, or if the space has been deallocated
by a call to free or realloc, the behavior is undefined.
656
srand
Synopsis
void srand(unsigned int seed);
Description
srand uses the argument seed as a seed for a new sequence of pseudo-random numbers to be returned by
subsequent calls to rand. If srand is called with the same seed value, the same sequence of pseudo-random
numbers is generated.
If rand is called before any calls to srand have been made, a sequence is generated as if srand is first called with
a seed value of 1.
See Also
rand
657
strtod
Synopsis
double strtod(const char *nptr,
char **endptr);
Description
strtod converts the initial portion of the string pointed to by nptr to a double representation.
First, strtod decomposes the input string into three parts: an initial, possibly empty, sequence of white-space
characters (as specified by isspace), a subject sequence resembling a floating-point constant, and a final string
of one or more unrecognized characters, including the terminating null character of the input string. strtod then
attempts to convert the subject sequence to a floating-point number, and return the result.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The subject sequence contains no characters if the input
string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or
a permissible letter or digit.
The expected form of the subject sequence is an optional plus or minus sign followed by a nonempty sequence
of decimal digits optionally containing a decimal-point character, then an optional exponent part.
If the subject sequence begins with a minus sign, the value resulting from the conversion is negated.
A pointer to the final string is stored in the object pointed to by strtod, provided that endptr is not a null
pointer.
If the subject sequence is empty or does not have the expected form, no conversion is performed, the value of
nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
strtod returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, HUGE_VAL is returned according to the sign of the value, if
any, and the value of the macro errno is stored in errno.
658
strtof
Synopsis
float strtof(const char *nptr,
char **endptr);
Description
strtof converts the initial portion of the string pointed to by nptr to a double representation.
First, strtof decomposes the input string into three parts: an initial, possibly empty, sequence of white-space
characters (as specified by isspace), a subject sequence resembling a floating-point constant, and a final string
of one or more unrecognized characters, including the terminating null character of the input string. strtof then
attempts to convert the subject sequence to a floating-point number, and return the result.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The subject sequence contains no characters if the input
string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or
a permissible letter or digit.
The expected form of the subject sequence is an optional plus or minus sign followed by a nonempty sequence
of decimal digits optionally containing a decimal-point character, then an optional exponent part.
If the subject sequence begins with a minus sign, the value resulting from the conversion is negated. A pointer
to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
If the subject sequence is empty or does not have the expected form, no conversion is performed, the value of
nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
strtof returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, HUGE_VALF is returned according to the sign of the value, if
any, and the value of the macro errno is stored in errno.
659
strtol
Synopsis
long int strtol(const char *nptr,
char **endptr,
int base);
Description
strtol converts the initial portion of the string pointed to by nptr to a long int representation.
First, strtol decomposes the input string into three parts: an initial, possibly empty, sequence of white-space
characters (as specified by isspace), a subject sequence resembling an integer represented in some radix
determined by the value of base, and a final string of one or more unrecognized characters, including the
terminating null character of the input string. strtol then attempts to convert the subject sequence to an integer,
and return the result.
When converting, no integer suffix (such as U, L, UL, LL, ULL) is allowed.
If the value of base is zero, the expected form of the subject sequence is an optional plus or minus sign followed
by an integer constant.
If the value of base is between 2 and 36 (inclusive), the expected form of the subject sequence is an optional
plus or minus sign followed by a sequence of letters and digits representing an integer with the radix specified
by base. The letters from a (or A) through z (or Z) represent the values 10 through 35; only letters and digits
whose ascribed values are less than that of base are permitted.
If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits,
following the optional sign.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The subject sequence contains no characters if the input
string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or
a permissible letter or digit.
If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting
with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the
value of base is between 2 and 36, it is used as the base for conversion.
If the subject sequence begins with a minus sign, the value resulting from the conversion is negated.
A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null
pointer.
If the subject sequence is empty or does not have the expected form, no conversion is performed, the value of
nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
660
strtol returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, LONG_MIN or LONG_MAX is returned according to the sign
of the value, if any, and the value of the macro errno is stored in errno.
661
strtoll
Synopsis
long long int strtoll(const char *nptr,
char **endptr,
int base);
Description
strtoll converts the initial portion of the string pointed to by nptr to a long int representation.
First, strtoll decomposes the input string into three parts: an initial, possibly empty, sequence of white-space
characters (as specified by isspace), a subject sequence resembling an integer represented in some radix
determined by the value of base, and a final string of one or more unrecognized characters, including the
terminating null character of the input string. strtoll then attempts to convert the subject sequence to an
integer, and return the result.
When converting, no integer suffix (such as U, L, UL, LL, ULL) is allowed.
If the value of base is zero, the expected form of the subject sequence is an optional plus or minus sign followed
by an integer constant.
If the value of base is between 2 and 36 (inclusive), the expected form of the subject sequence is an optional
plus or minus sign followed by a sequence of letters and digits representing an integer with the radix specified
by base. The letters from a (or A) through z (or Z) represent the values 10 through 35; only letters and digits
whose ascribed values are less than that of base are permitted.
If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits,
following the optional sign.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The subject sequence contains no characters if the input
string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or
a permissible letter or digit.
If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting
with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the
value of base is between 2 and 36, it is used as the base for conversion.
If the subject sequence begins with a minus sign, the value resulting from the conversion is negated.
A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null
pointer.
If the subject sequence is empty or does not have the expected form, no conversion is performed, the value of
nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
662
strtoll returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, LLONG_MIN or LLONG_MAX is returned according to the
sign of the value, if any, and the value of the macro ERANGE is stored in errno.
663
strtoul
Synopsis
unsigned long int strtoul(const char *nptr,
char **endptr,
int base);
Description
strtoul converts the initial portion of the string pointed to by nptr to a long int representation.
First, strtoul decomposes the input string into three parts: an initial, possibly empty, sequence of white-space
characters (as specified by isspace), a subject sequence resembling an integer represented in some radix
determined by the value of base, and a final string of one or more unrecognized characters, including the
terminating null character of the input string. strtoul then attempts to convert the subject sequence to an
integer, and return the result.
When converting, no integer suffix (such as U, L, UL, LL, ULL) is allowed.
If the value of base is zero, the expected form of the subject sequence is an optional plus or minus sign followed
by an integer constant.
If the value of base is between 2 and 36 (inclusive), the expected form of the subject sequence is an optional
plus or minus sign followed by a sequence of letters and digits representing an integer with the radix specified
by base. The letters from a (or A) through z (or Z) represent the values 10 through 35; only letters and digits
whose ascribed values are less than that of base are permitted.
If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits,
following the optional sign.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The subject sequence contains no characters if the input
string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or
a permissible letter or digit.
If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting
with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the
value of base is between 2 and 36, it is used as the base for conversion.
If the subject sequence begins with a minus sign, the value resulting from the conversion is negated.
A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null
pointer.
If the subject sequence is empty or does not have the expected form, no conversion is performed, the value of
nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
664
strtoul returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, LONG_MAX or ULONG_MAX is returned according to the
sign of the value, if any, and the value of the macro ERANGE is stored in errno.
665
strtoull
Synopsis
unsigned long long int strtoull(const char *nptr,
char **endptr,
int base);
Description
strtoull converts the initial portion of the string pointed to by nptr to a long int representation.
First, strtoull decomposes the input string into three parts: an initial, possibly empty, sequence of white-space
characters (as specified by isspace), a subject sequence resembling an integer represented in some radix
determined by the value of base, and a final string of one or more unrecognized characters, including the
terminating null character of the input string. strtoull then attempts to convert the subject sequence to an
integer, and return the result.
When converting, no integer suffix (such as U, L, UL, LL, ULL) is allowed.
If the value of base is zero, the expected form of the subject sequence is an optional plus or minus sign followed
by an integer constant.
If the value of base is between 2 and 36 (inclusive), the expected form of the subject sequence is an optional
plus or minus sign followed by a sequence of letters and digits representing an integer with the radix specified
by base. The letters from a (or A) through z (or Z) represent the values 10 through 35; only letters and digits
whose ascribed values are less than that of base are permitted.
If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits,
following the optional sign.
The subject sequence is defined as the longest initial subsequence of the input string, starting with the first nonwhite-space character, that is of the expected form. The subject sequence contains no characters if the input
string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or
a permissible letter or digit.
If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting
with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the
value of base is between 2 and 36, it is used as the base for conversion.
If the subject sequence begins with a minus sign, the value resulting from the conversion is negated.
A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null
pointer.
If the subject sequence is empty or does not have the expected form, no conversion is performed, the value of
nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
666
strtoull returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct
value is outside the range of representable values, LLONG_MAX or ULLONG_MAX is returned according to the
sign of the value, if any, and the value of the macro ERANGE is stored in errno.
667
ulltoa
Synopsis
char *ulltoa(unsigned long long val,
char *buf,
int radix);
Description
ulltoa converts val to a string in base radix and places the result in buf.
ulltoa returns buf as the result.
If radix is greater than 36, the result is undefined.
See Also
itoa, ltoa, lltoa, ultoa, utoa
668
ultoa
Synopsis
char *ultoa(unsigned long val,
char *buf,
int radix);
Description
ultoa converts val to a string in base radix and places the result in buf.
ultoa returns buf as the result.
If radix is greater than 36, the result is undefined.
See Also
itoa, ltoa, lltoa, ulltoa, utoa
669
utoa
Synopsis
char *utoa(unsigned val,
char *buf,
int radix);
Description
utoa converts val to a string in base radix and places the result in buf.
utoa returns buf as the result.
If radix is greater than 36, the result is undefined.
See Also
itoa, ltoa, lltoa, ultoa, ulltoa
670
<string.h>
Overview
The header file <string.h> defines functions that operate on arrays that are interpreted as null-terminated
strings.
Various methods are used for determining the lengths of the arrays, but in all cases a char * or void * argument
points to the initial (lowest addressed) character of the array. If an array is accessed beyond the end of an object,
the behavior is undefined.
Where an argument declared as size_t n specifies the length of an array for a function, n can have the value zero
on a call to that function. Unless explicitly stated otherwise in the description of a particular function, pointer
arguments must have valid values on a call with a zero size. On such a call, a function that locates a character
finds no occurrence, a function that compares two character sequences returns zero, and a function that copies
characters copies zero characters.
API Summary
Copying functions
memccpy
memcpy
Copy memory
memcpy_fast
Copy memory
memmove
mempcpy
strcat
Concatenate strings
strcpy
Copy string
strdup
strlcat
strlcpy
strncat
strncpy
strndup
Comparison functions
memcmp
Compare memory
strcasecmp
671
strcmp
Compare strings
strncasecmp
strncmp
Search functions
memchr
strcasestr
strchr
strcspn
strncasestr
strnchr
strnlen
strnstr
strpbrk
strrchr
strsep
strspn
strstr
strtok
strtok_r
Miscellaneous functions
memset
strerror
strlen
672
memccpy
Synopsis
void *memccpy(void *s1,
const void *s2,
int c,
size_t n);
Description
memccpy copies at most n characters from the object pointed to by s2 into the object pointed to by s1. The
copying stops as soon as n characters are copied or the character c is copied into the destination object pointed
to by s1. The behavior of memccpy is undefined if copying takes place between objects that overlap.
memccpy returns a pointer to the character immediately following c in s1, or NULL if c was not found in the first
n characters of s2.
Note
memccpy conforms to POSIX.1-2008.
673
memchr
Synopsis
void *memchr(const void *s,
int c,
size_t n);
Description
memchr locates the first occurrence of c (converted to an unsigned char) in the initial n characters (each
interpreted as unsigned char) of the object pointed to by s. Unlike strchr, memchr does not terminate a search
when a null character is found in the object pointed to by s.
memchr returns a pointer to the located character, or a null pointer if c does not occur in the object.
674
memcmp
Synopsis
int memcmp(const void *s1,
const void *s2,
size_t n);
Description
memcmp compares the first n characters of the object pointed to by s1 to the first n characters of the object
pointed to by s2. memcmp returns an integer greater than, equal to, or less than zero as the object pointed to
by s1 is greater than, equal to, or less than the object pointed to by s2.
675
memcpy
Synopsis
void *memcpy(void *s1,
const void *s2,
size_t n);
Description
memcpy copies n characters from the object pointed to by s2 into the object pointed to by s1. The behavior of
memcpy is undefined if copying takes place between objects that overlap.
memcpy returns the value of s1.
676
memcpy_fast
Synopsis
void *memcpy_fast(void *s1,
const void *s2,
size_t n);
Description
memcpy_fast copies n characters from the object pointed to by s2 into the object pointed to by s1. The
behavior of memcpy_fast is undefined if copying takes place between objects that overlap. The implementation
of memcpy_fast is optimized for speed for all cases of memcpy and as such has a large code memory
requirement. This function is implemented for little-endian ARM and 32-bit Thumb-2 instruction sets only.
memcpy_fast returns the value of s1.
677
memmove
Synopsis
void *memmove(void *s1,
const void *s2,
size_t n);
Description
memmove copies n characters from the object pointed to by s2 into the object pointed to by s1 ensuring that
if s1 and s2 overlap, the copy works correctly. Copying takes place as if the n characters from the object pointed
to by s2 are first copied into a temporary array of n characters that does not overlap the objects pointed to by s1
and s2, and then the n characters from the temporary array are copied into the object pointed to by s1.
memmove returns the value of s1.
678
mempcpy
Synopsis
void *mempcpy(void *s1,
const void *s2,
size_t n);
Description
mempcpy copies n characters from the object pointed to by s2 into the object pointed to by s1. The behavior of
mempcpy is undefined if copying takes place between objects that overlap.
mempcpy returns a pointer to the byte following the last written byte.
Note
This is an extension found in GNU libc.
679
memset
Synopsis
void *memset(void *s,
int c,
size_t n);
Description
memset copies the value of c (converted to an unsigned char) into each of the first n characters of the object
pointed to by s.
memset returns the value of s.
680
strcasecmp
Synopsis
int strcasecmp(const char *s1,
const char *s2);
Description
strcasecmp compares the string pointed to by s1 to the string pointed to by s2 ignoring differences in case.
strcasecmp returns an integer greater than, equal to, or less than zero if the string pointed to by s1 is greater
than, equal to, or less than the string pointed to by s2.
Note
strcasecmp conforms to POSIX.1-2008.
681
strcasestr
Synopsis
char *strcasestr(const char *s1,
const char *s2);
Description
strcasestr locates the first occurrence in the string pointed to by s1 of the sequence of characters (excluding the
terminating null character) in the string pointed to by s2 without regard to character case.
strcasestr returns a pointer to the located string, or a null pointer if the string is not found. If s2 points to a string
with zero length, strcasestr returns s1.
Note
strcasestr is an extension commonly found in Linux and BSD C libraries.
682
strcat
Synopsis
char *strcat(char *s1,
const char *s2);
Description
strcat appends a copy of the string pointed to by s2 (including the terminating null character) to the end of the
string pointed to by s1. The initial character of s2 overwrites the null character at the end of s1. The behavior of
strcat is undefined if copying takes place between objects that overlap.
strcat returns the value of s1.
683
strchr
Synopsis
char *strchr(const char *s,
int c);
Description
strchr locates the first occurrence of c (converted to a char) in the string pointed to by s. The terminating null
character is considered to be part of the string.
strchr returns a pointer to the located character, or a null pointer if c does not occur in the string.
684
strcmp
Synopsis
int strcmp(const char *s1,
const char *s2);
Description
strcmp compares the string pointed to by s1 to the string pointed to by s2. strcmp returns an integer greater
than, equal to, or less than zero if the string pointed to by s1 is greater than, equal to, or less than the string
pointed to by s2.
685
strcpy
Synopsis
char *strcpy(char *s1,
const char *s2);
Description
strcpy copies the string pointed to by s2 (including the terminating null character) into the array pointed to by
s1. The behavior of strcpy is undefined if copying takes place between objects that overlap.
strcpy returns the value of s1.
686
strcspn
Synopsis
size_t strcspn(const char *s1,
const char *s2);
Description
strcspn computes the length of the maximum initial segment of the string pointed to by s1 which consists
entirely of characters not from the string pointed to by s2.
strcspn returns the length of the segment.
687
strdup
Synopsis
char *strdup(const char *s1);
Description
strdup duplicates the string pointed to by s1 by using malloc to allocate memory for a copy of s and then
copying s, including the terminating null, to that memory strdup returns a pointer to the new string or a null
pointer if the new string cannot be created. The returned pointer can be passed to free.
Note
strdup conforms to POSIX.1-2008 and SC22 TR 24731-2.
688
strerror
Synopsis
char *strerror(int num);
Description
strerror maps the number in num to a message string. Typically, the values for num come from errno, but
strerror can map any value of type int to a message.
strerror returns a pointer to the message string. The program must not modify the returned message string. The
message may be overwritten by a subsequent call to strerror.
689
strlcat
Synopsis
size_t strlcat(char *s1,
const char *s2,
size_t n);
Description
strlcat appends no more than nstrlen(dst)1 characters pointed to by s2 into the array pointed to by s1 and
always terminates the result with a null character if n is greater than zero. Both the strings s1 and s2 must be
terminated with a null character on entry to strlcat and a byte for the terminating null should be included in n.
The behavior of strlcat is undefined if copying takes place between objects that overlap.
strlcat returns the number of characters it tried to copy, which is the sum of the lengths of the strings s1 and s2
or n, whichever is smaller.
Note
strlcat is commonly found in OpenBSD libraries.
690
strlcpy
Synopsis
size_t strlcpy(char *s1,
const char *s2,
size_t n);
Description
strlcpy copies up to n1 characters from the string pointed to by s2 into the array pointed to by s1 and always
terminates the result with a null character. The behavior of strlcpy is undefined if copying takes place between
objects that overlap.
strlcpy returns the number of characters it tried to copy, which is the length of the string s2 or n, whichever is
smaller.
Note
strlcpy is commonly found in OpenBSD libraries and contrasts with strncpy in that the resulting string is always
terminated with a null character.
691
strlen
Synopsis
size_t strlen(const char *s);
Description
strlen returns the length of the string pointed to by s, that is the number of characters that precede the
terminating null character.
692
strncasecmp
Synopsis
int strncasecmp(const char *s1,
const char *s2,
size_t n);
Description
strncasecmp compares not more than n characters from the array pointed to by s1 to the array pointed to by s2
ignoring differences in case. Characters that follow a null character are not compared.
strncasecmp returns an integer greater than, equal to, or less than zero, if the possibly null-terminated array
pointed to by s1 is greater than, equal to, or less than the possibly null-terminated array pointed to by s2.
Note
strncasecmp conforms to POSIX.1-2008.
693
strncasestr
Synopsis
char *strncasestr(const char *s1,
const char *s2,
size_t n);
Description
strncasestr searches at most n characters to locate the first occurrence in the string pointed to by s1 of the
sequence of characters (excluding the terminating null character) in the string pointed to by s2 without regard
to character case.
strncasestr returns a pointer to the located string, or a null pointer if the string is not found. If s2 points to a
string with zero length, strncasestr returns s1.
Note
strncasestr is an extension commonly found in Linux and BSD C libraries.
694
strncat
Synopsis
char *strncat(char *s1,
const char *s2,
size_t n);
Description
strncat appends not more than n characters from the array pointed to by s2 to the end of the string pointed to
by s1. A null character in s1 and characters that follow it are not appended. The initial character of s2 overwrites
the null character at the end of s1. A terminating null character is always appended to the result. The behavior of
strncat is undefined if copying takes place between objects that overlap.
strncat returns the value of s1.
695
strnchr
Synopsis
char *strnchr(const char *str,
size_t n,
int ch);
Description
strnchr searches not more than n characters to locate the first occurrence of c (converted to a char) in the string
pointed to by s. The terminating null character is considered to be part of the string.
strnchr returns a pointer to the located character, or a null pointer if c does not occur in the string.
696
strncmp
Synopsis
int strncmp(const char *s1,
const char *s2,
size_t n);
Description
strncmp compares not more than n characters from the array pointed to by s1 to the array pointed to by s2.
Characters that follow a null character are not compared.
strncmp returns an integer greater than, equal to, or less than zero, if the possibly null-terminated array pointed
to by s1 is greater than, equal to, or less than the possibly null-terminated array pointed to by s2.
697
strncpy
Synopsis
char *strncpy(char *s1,
const char *s2,
size_t n);
Description
strncpy copies not more than n characters from the array pointed to by s2 to the array pointed to by s1.
Characters that follow a null character in s2 are not copied. The behavior of strncpy is undefined if copying takes
place between objects that overlap. If the array pointed to by s2 is a string that is shorter than n characters, null
characters are appended to the copy in the array pointed to by s1, until n characters in all have been written.
strncpy returns the value of s1.
Note
No null character is implicitly appended to the end of s1, so s1 will only be terminated by a null character if the
length of the string pointed to by s2 is less than n.
698
strndup
Synopsis
char *strndup(const char *s1,
size_t n);
Description
strndup duplicates at most n characters from the the string pointed to by s1 by using malloc to allocate memory
for a copy of s1.
If the length of string pointed to by s1 is greater than n characters, only n characters will be duplicated. If n is
greater than the length of string pointed to by s1, all characters in the string are copied into the allocated array
including the terminating null character.
strndup returns a pointer to the new string or a null pointer if the new string cannot be created. The returned
pointer can be passed to free.
Note
strndup conforms to POSIX.1-2008 and SC22 TR 24731-2.
699
strnlen
Synopsis
size_t strnlen(const char *s,
size_t n);
Description
strnlen returns the length of the string pointed to by s, up to a maximum of n characters. strnlen only examines
the first n characters of the string s.
Note
strnlen conforms to POSIX.1-2008.
700
strnstr
Synopsis
char *strnstr(const char *s1,
const char *s2,
size_t n);
Description
strnstr searches at most n characters to locate the first occurrence in the string pointed to by s1 of the sequence
of characters (excluding the terminating null character) in the string pointed to by s2.
strnstr returns a pointer to the located string, or a null pointer if the string is not found. If s2 points to a string
with zero length, strnstr returns s1.
Note
strnstr is an extension commonly found in Linux and BSD C libraries.
701
strpbrk
Synopsis
char *strpbrk(const char *s1,
const char *s2);
Description
strpbrk locates the first occurrence in the string pointed to by s1 of any character from the string pointed to by
s2.
strpbrk returns a pointer to the character, or a null pointer if no character from s2 occurs in s1.
702
strrchr
Synopsis
char *strrchr(const char *s,
int c);
Description
strrchr locates the last occurrence of c (converted to a char) in the string pointed to by s. The terminating null
character is considered to be part of the string.
strrchr returns a pointer to the character, or a null pointer if c does not occur in the string.
703
strsep
Synopsis
char *strsep(char **stringp,
const char *delim);
Description
strsep locates, in the string referenced by *stringp, the first occurrence of any character in the string delim (or
the terminating null character) and replaces it with a null character. The location of the next character after the
delimiter character (or NULL, if the end of the string was reached) is stored in *stringp. The original value of
*stringp is returned.
An empty field (that is, a character in the string delim occurs as the first character of *stringp can be detected by
comparing the location referenced by the returned pointer to the null character.
If *stringp is initially null, strsep returns null.
Note
strsep is an extension commonly found in Linux and BSD C libraries.
704
strspn
Synopsis
size_t strspn(const char *s1,
const char *s2);
Description
strspn computes the length of the maximum initial segment of the string pointed to by s1 which consists
entirely of characters from the string pointed to by s2.
strspn returns the length of the segment.
705
strstr
Synopsis
char *strstr(const char *s1,
const char *s2);
Description
strstr locates the first occurrence in the string pointed to by s1 of the sequence of characters (excluding the
terminating null character) in the string pointed to by s2.
strstr returns a pointer to the located string, or a null pointer if the string is not found. If s2 points to a string with
zero length, strstr returns s1.
706
strtok
Synopsis
char *strtok(char *s1,
const char *s2);
Description
strtok A sequence of calls to strtok breaks the string pointed to by s1 into a sequence of tokens, each of which
is delimited by a character from the string pointed to by s2. The first call in the sequence has a non-null first
argument; subsequent calls in the sequence have a null first argument. The separator string pointed to by s2
may be different from call to call.
The first call in the sequence searches the string pointed to by s1 for the first character that is not contained in
the current separator string pointed to by s2. If no such character is found, then there are no tokens in the string
pointed to by s1 and strtok returns a null pointer. If such a character is found, it is the start of the first token.
strtok then searches from there for a character that is contained in the current separator string. If no such
character is found, the current token extends to the end of the string pointed to by s1, and subsequent searches
for a token will return a null pointer. If such a character is found, it is overwritten by a null character, which
terminates the current token. strtok saves a pointer to the following character, from which the next search for a
token will start.
Each subsequent call, with a null pointer as the value of the first argument, starts searching from the saved
pointer and behaves as described above.
Note
strtok maintains static state and is therefore not reentrant and not thread safe. See strtok_r for a thread-safe and
reentrant variant.
See Also
strsep, strtok_r.
707
strtok_r
Synopsis
char *strtok_r(char *s1,
const char *s2,
char **s3);
Description
strtok_r is a reentrant version of the function strtok where the state is maintained in the object of type char *
pointed to by s3.
Note
strtok_r conforms to POSIX.1-2008 and is commonly found in Linux and BSD C libraries.
See Also
strtok.
708
<time.h>
API Summary
Types
clock_t
Clock type
time_t
Time type
tm
Time structure
Functions
asctime
asctime_r
ctime
ctime_r
difftime
gmtime
gmtime_r
localtime
localtime_r
mktime
strftime
709
asctime
Synopsis
char *asctime(const tm *tp);
Description
asctime converts the *tp struct to a null terminated string of the form Sun Sep 16 01:03:52 1973. The
returned string is held in a static buffer. asctime is not re-entrant.
710
asctime_r
Synopsis
char *asctime_r(const tm *tp,
char *buf);
Description
asctime_r converts the *tp struct to a null terminated string of the form Sun Sep 16 01:03:52 1973 in buf and
returns buf. The buf must point to an array at least 26 bytes in length.
711
clock_t
Synopsis
typedef long clock_t;
Description
clock_t is the type returned by the clock function.
712
ctime
Synopsis
char *ctime(const time_t *tp);
Description
ctime converts the *tp to a null terminated string. The returned string is held in a static buffer, this function is
not re-entrant.
713
ctime_r
Synopsis
char *ctime_r(const time_t *tp,
char *buf);
Description
ctime_r converts the *tp to a null terminated string in buf and returns buf. The buf must point to an array at
least 26 bytes in length.
714
difftime
Synopsis
double difftime(time_t time2,
time_t time1);
Description
difftime returns time1 - time0 as a double precision number.
715
gmtime
Synopsis
gmtime(const time_t *tp);
Description
gmtime converts the *tp time format to a struct tm time format. The returned value points to a static object this function is not re-entrant.
716
gmtime_r
Synopsis
gmtime_r(const time_t *tp,
tm *result);
Description
gmtime_r converts the *tp time format to a struct tm time format in *result and returns result.
717
localtime
Synopsis
localtime(const time_t *tp);
Description
localtime converts the *tp time format to a struct tm local time format. The returned value points to a static
object - this function is not re-entrant.
718
localtime_r
Synopsis
localtime_r(const time_t *tp,
tm *result);
Description
localtime_r converts the *tp time format to a struct tm local time format in *result and returns result.
719
mktime
Synopsis
time_t mktime(tm *tp);
Description
mktime validates (and updates) the *tp struct to ensure that the tm_sec, tm_min, tm_hour, tm_mon fields
are within the supported integer ranges and the tm_mday, tm_mon and tm_year fields are consistent. The
validated *tp struct is converted to the number of seconds since UTC 1 January 1970 and returned.
720
strftime
Synopsis
size_t strftime(char *s,
size_t smax,
const char *fmt,
const tm *tp);
Description
strftime formats the *tp struct to a null terminated string of maximum size smax-1 into the array at *s based
on the fmt format string. The format string consists of conversion specifications and ordinary characters.
Conversion specifications start with a % character followed by an optional # character. The following conversion
specifications are supported:
Specification
Description
%s
%A
%b
%B
%c
%#c
%C
Century number
%d
%#d
%D
%e
%F
%h
%H
%#H
%I
%#I
%j
%#j
%k
721
%l
%m
%#m
%M
%#M
%n
%p
%r
%R
%S
%t
%T
Time as %H:%M:%S
%#S
%U
%#U
%w
%W
%#W
%x
%#x
%X
%y
%#y
%Y
%z,%Z
%%
722
time_t
Synopsis
typedef long time_t;
Description
time_t is a long type that represents the time in number of seconds since UTC 1 January 1970, negative values
indicate time before UTC 1 January 1970.
723
tm
Synopsis
typedef struct {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
} tm;
Description
tm structure has the following fields.
Member
Description
tm_sec
tm_min
tm_hour
tm_mday
tm_mon
tm_year
tm_wday
tm_yday
tm_isdst
724
<wchar.h>
API Summary
Character minimum and maximum values
WCHAR_MAX
WCHAR_MIN
Constants
WEOF
Types
wchar_t
wint_t
Copying functions
wcscat
Concatenate strings
wcscpy
Copy string
wcsncat
wcsncpy
wmemccpy
wmemcpy
Copy memory
wmemmove
wmempcpy
Comparison functions
wcscmp
Compare strings
wcsncmp
wmemcmp
Compare memory
Search functions
wcschr
wcscspn
wcsnchr
wcsnlen
wcsnstr
wcspbrk
wcsrchr
725
wcsspn
wcsstr
wcstok
wcstok_r
wmemchr
wstrsep
Miscellaneous functions
wcsdup
Duplicate string
wcslen
wmemset
mbrtowc_l
msbinit
wcrtomb
wcrtomb_l
wctob
wctob_l
mbrlen_l
mbsrtowcs
mbsrtowcs_l
btowc_l
726
WCHAR_MAX
Synopsis
#define WCHAR_MAX
...
Description
WCHAR_MAX is the maximum value for an object of type wchar_t. Although capable of storing larger values,
the maximum value implemented by the conversion functions in the library is the value 0x10FFFF defined by ISO
10646.
727
WCHAR_MIN
Synopsis
#define WCHAR_MIN
...
Description
WCHAR_MIN is the minimum value for an object of type wchar_t.
728
WEOF
Synopsis
#define WEOF ((wint_t)~0U)
Description
WEOF expands to a constant value that does not correspond to any character in the wide character set. It is
typically used to indicate an end of file condition.
729
btowc
Synopsis
wint_t btowc(int c);
Description
btowc function determines whether c constitutes a valid single-byte character. If c is a valid single-byte
character, btowc returns the wide character representation of that character
btowc returns WEOF if c has the value EOF or if (unsigned char)c does not constitute a valid single-byte
character in the initial shift state.
730
btowc_l
Synopsis
wint_t btowc_l(int c,
locale_t loc);
Description
btowc_l function determines whether c constitutes a valid single-byte character in the locale loc. If c is a valid
single-byte character, btowc_l returns the wide character representation of that character
btowc_l returns WEOF if c has the value EOF or if (unsigned char)c does not constitute a valid single-byte
character in the initial shift state.
731
mbrlen
Synopsis
size_t mbrlen(const char *s,
size_t n,
mbstate_t *ps);
Note
mbrlen function is equivalent to the call:
mbrtowc(NULL, s, n, ps != NULL ? ps : &internal);
where internal is the mbstate_t object for the mbrlen function, except that the expression designated by ps is
evaluated only once.
732
mbrlen_l
Synopsis
size_t mbrlen_l(const char *s,
size_t n,
mbstate_t *ps,
locale_t loc);
Note
mbrlen_l function is equivalent to the call:
mbrtowc_l(NULL, s, n, ps != NULL ? ps : &internal, loc);
where internal is the mbstate_t object for the mbrlen function, except that the expression designated by ps is
evaluated only once.
733
mbrtowc
Synopsis
size_t mbrtowc(wchar_t *pwc,
const char *s,
size_t n,
mbstate_t *ps);
Description
mbrtowc converts a single multi-byte character to a wide character in the current locale.
If s is a null pointer, mbrtowc is equivalent to mbrtowc(NULL, "", 1, ps), ignoring pwc and n.
If s is not null and the object that s points to is a wide-character null character, mbrtowc returns 0.
If s is not null and the object that points to forms a valid multi-byte character with a most n bytes, mbrtowc
returns the length in bytes of the multi-byte character and stores that wide character to the object pointed to by
pwc (if pwc is not null).
If the object that points to forms an incomplete, but possibly valid, multi-byte character, mbrtowc returns 2. If
the object that points to does not form a partial multi-byte character, mbrtowc returns 1.
See Also
mbtowc, mbrtowc_l
734
mbrtowc_l
Synopsis
size_t mbrtowc_l(wchar_t *pwc,
const char *s,
size_t n,
mbstate_t *ps,
locale_t loc);
Description
mbrtowc_l converts a single multi-byte character to a wide character in the locale loc.
If s is a null pointer, mbrtowc_l is equivalent to mbrtowc(NULL, "", 1, ps), ignoring pwc and n.
If s is not null and the object that s points to is a wide-character null character, mbrtowc_l returns 0.
If s is not null and the object that points to forms a valid multi-byte character with a most n bytes, mbrtowc_l
returns the length in bytes of the multi-byte character and stores that wide character to the object pointed to by
pwc (if pwc is not null).
If the object that points to forms an incomplete, but possibly valid, multi-byte character, mbrtowc_l returns 2.
If the object that points to does not form a partial multi-byte character, mbrtowc_l returns 1.
See Also
mbrtowc, mbtowc_l
735
mbsrtowcs
Synopsis
size_t mbsrtowcs(wchar_t *dst,
const char **src,
size_t len,
mbstate_t *ps);
Description
mbsrtowcs converts a sequence of multi-byte characters that begins in the conversion state described by the
object pointed to by ps, from the array indirectly pointed to by src into a sequence of corresponding wide
characters If dst is not a null pointer, the converted characters are stored into the array pointed to by dst.
Conversion continues up to and including a terminating null character, which is also stored.
Conversion stops earlier in two cases: when a sequence of bytes is encountered that does not form a valid multibyte character, or (if dst is not a null pointer) when len wide characters have been stored into the array pointed
to by dst. Each conversion takes place as if by a call to the mbrtowc function.
If dst is not a null pointer, the pointer object pointed to by src is assigned either a null pointer (if conversion
stopped due to reaching a terminating null character) or the address just past the last multi-byte character
converted (if any). If conversion stopped due to reaching a terminating null character and if dst is not a null
pointer, the resulting state described is the initial conversion state.
See Also
mbsrtowcs_l, mbrtowc
736
mbsrtowcs_l
Synopsis
size_t mbsrtowcs_l(wchar_t *dst,
const char **src,
size_t len,
mbstate_t *ps,
locale_t loc);
Description
mbsrtowcs_l converts a sequence of multi-byte characters that begins in the conversion state described by
the object pointed to by ps, from the array indirectly pointed to by src into a sequence of corresponding wide
characters If dst is not a null pointer, the converted characters are stored into the array pointed to by dst.
Conversion continues up to and including a terminating null character, which is also stored.
Conversion stops earlier in two cases: when a sequence of bytes is encountered that does not form a valid multibyte character, or (if dst is not a null pointer) when len wide characters have been stored into the array pointed
to by dst. Each conversion takes place as if by a call to the mbrtowc function.
If dst is not a null pointer, the pointer object pointed to by src is assigned either a null pointer (if conversion
stopped due to reaching a terminating null character) or the address just past the last multi-byte character
converted (if any). If conversion stopped due to reaching a terminating null character and if dst is not a null
pointer, the resulting state described is the initial conversion state.
See Also
mbsrtowcs_l, mbrtowc
737
msbinit
Synopsis
int msbinit(const mbstate_t *ps);
Description
msbinit function returns nonzero if ps is a null pointer or if the pointed-to object describes an initial conversion
state; otherwise, msbinit returns zero.
738
wchar_t
Synopsis
typedef __RAL_WCHAR_T wchar_t;
Description
wchar_t holds a single wide character.
Depending on implementation you can control whether wchar_t is represented by a short 16-bit type or the
standard 32-bit type.
739
wcrtomb
Synopsis
size_t wcrtomb(char *s,
wchar_t wc,
mbstate_t *ps);
If s is a null pointer, wcrtomb function is equivalent to the call wcrtomb(buf, L'\0', ps) where buf is an
internal buffer.
If s is not a null pointer, wcrtomb determines the number of bytes needed to represent the multibyte character
that corresponds to the wide character given by wc, and stores the multibyte character representation in
the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If wc is a null wide
character, a null byte is stored; the resulting state described is the initial conversion state.
wcrtomb returns the number of bytes stored in the array object. When wc is not a valid wide character, an
encoding error occurs: wcrtomb stores the value of the macro EILSEQ in errno and returns (size_t)(-1); the
conversion state is unspecified.
740
wcrtomb_l
Synopsis
size_t wcrtomb_l(char *s,
wchar_t wc,
mbstate_t *ps,
locale_t loc);
If s is a null pointer, wcrtomb_l function is equivalent to the call wcrtomb_l(buf, L'\0', ps, loc)
where buf is an internal buffer.
If s is not a null pointer, wcrtomb_l determines the number of bytes needed to represent the multibyte
character that corresponds to the wide character given by wc, and stores the multibyte character representation
in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If wc is a null wide
character, a null byte is stored; the resulting state described is the initial conversion state.
wcrtomb_l returns the number of bytes stored in the array object. When wc is not a valid wide character, an
encoding error occurs: wcrtomb_l stores the value of the macro EILSEQ in errno and returns (size_t)(-1);
the conversion state is unspecified.
741
wcscat
Synopsis
wchar_t *wcscat(wchar_t *s1,
const wchar_t *s2);
Description
wcscat appends a copy of the wide string pointed to by s2 (including the terminating null wide character) to the
end of the wide string pointed to by s1. The initial character of s2 overwrites the null wide character at the end
of s1. The behavior of wcscat is undefined if copying takes place between objects that overlap.
wcscat returns the value of s1.
742
wcschr
Synopsis
wchar_t *wcschr(const wchar_t *s,
wchar_t c);
Description
wcschr locates the first occurrence of c in the wide string pointed to by s. The terminating wide null character is
considered to be part of the string.
wcschr returns a pointer to the located wide character, or a null pointer if c does not occur in the string.
743
wcscmp
Synopsis
int wcscmp(const wchar_t *s1,
const wchar_t *s2);
Description
wcscmp compares the wide string pointed to by s1 to the wide string pointed to by s2. wcscmp returns an
integer greater than, equal to, or less than zero if the wide string pointed to by s1 is greater than, equal to, or less
than the wide string pointed to by s2.
744
wcscpy
Synopsis
wchar_t *wcscpy(wchar_t *s1,
const wchar_t *s2);
Description
wcscpy copies the wide string pointed to by s2 (including the terminating null wide character) into the array
pointed to by s1. The behavior of wcscpy is undefined if copying takes place between objects that overlap.
wcscpy returns the value of s1.
745
wcscspn
Synopsis
size_t wcscspn(const wchar_t *s1,
const wchar_t *s2);
Description
wcscspn computes the length of the maximum initial segment of the wide string pointed to by s1 which
consists entirely of wide characters not from the wide string pointed to by s2.
wcscspn returns the length of the segment.
746
wcsdup
Synopsis
wchar_t *wcsdup(const wchar_t *s1);
Description
wcsdup duplicates the wide string pointed to by s1 by using malloc to allocate memory for a copy of s and then
copying s, including the terminating wide null character, to that memory. The returned pointer can be passed to
free. wcsdup returns a pointer to the new wide string or a null pointer if the new string cannot be created.
Note
wcsdup is an extension commonly found in Linux and BSD C libraries.
747
wcslen
Synopsis
size_t wcslen(const wchar_t *s);
Description
wcslen returns the length of the wide string pointed to by s, that is the number of wide characters that precede
the terminating null wide character.
748
wcsncat
Synopsis
wchar_t *wcsncat(wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wcsncat appends not more than n wude characters from the array pointed to by s2 to the end of the wide string
pointed to by s1. A null wide character in s1 and wide characters that follow it are not appended. The initial
wide character of s2 overwrites the null wide character at the end of s1. A terminating wide null character is
always appended to the result. The behavior of wcsncat is undefined if copying takes place between objects
that overlap.
wcsncat returns the value of s1.
749
wcsnchr
Synopsis
wchar_t *wcsnchr(const wchar_t *str,
size_t n,
wchar_t ch);
Description
wcsnchr searches not more than n wide characters to locate the first occurrence of c in the wide string pointed
to by s. The terminating wide null character is considered to be part of the wide string.
wcsnchr returns a pointer to the located wide character, or a null pointer if c does not occur in the string.
750
wcsncmp
Synopsis
int wcsncmp(const wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wcsncmp compares not more than n wide characters from the array pointed to by s1 to the array pointed to by
s2. Characters that follow a null wide character are not compared.
wcsncmp returns an integer greater than, equal to, or less than zero, if the possibly null-terminated array
pointed to by s1 is greater than, equal to, or less than the possibly null-terminated array pointed to by s2.
751
wcsncpy
Synopsis
wchar_t *wcsncpy(wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wcsncpy copies not more than n wide characters from the array pointed to by s2 to the array pointed to by s1.
Wide characters that follow a null wide character in s2 are not copied. The behavior of wcsncpy is undefined
if copying takes place between objects that overlap. If the array pointed to by s2 is a wide string that is shorter
than n wide characters, null wide characters are appended to the copy in the array pointed to by s1, until n
characters in all have been written.
wcsncpy returns the value of s1.
752
wcsnlen
Synopsis
size_t wcsnlen(const wchar_t *s,
size_t n);
Description
this returns the length of the wide string pointed to by s, up to a maximum of n wide characters. wcsnlen only
examines the first n wide characters of the string s.
Note
wcsnlen is an extension commonly found in Linux and BSD C libraries.
753
wcsnstr
Synopsis
wchar_t *wcsnstr(const wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wcsnstr searches at most n wide characters to locate the first occurrence in the wide string pointed to by s1 of
the sequence of wide characters (excluding the terminating null wide character) in the wide string pointed to by
s2.
wcsnstr returns a pointer to the located string, or a null pointer if the string is not found. If s2 points to a string
with zero length, wcsnstr returns s1.
Note
wcsnstr is an extension commonly found in Linux and BSD C libraries.
754
wcspbrk
Synopsis
wchar_t *wcspbrk(const wchar_t *s1,
const wchar_t *s2);
Description
wcspbrk locates the first occurrence in the wide string pointed to by s1 of any wide character from the wide
string pointed to by s2.
wcspbrk returns a pointer to the wide character, or a null pointer if no wide character from s2 occurs in s1.
755
wcsrchr
Synopsis
wchar_t *wcsrchr(const wchar_t *s,
wchar_t c);
Description
wcsrchr locates the last occurrence of c in the wide string pointed to by s. The terminating wide null character is
considered to be part of the string.
wcsrchr returns a pointer to the wide character, or a null pointer if c does not occur in the wide string.
756
wcsspn
Synopsis
size_t wcsspn(const wchar_t *s1,
const wchar_t *s2);
Description
wcsspn computes the length of the maximum initial segment of the wide string pointed to by s1 which consists
entirely of wide characters from the wide string pointed to by s2.
wcsspn returns the length of the segment.
757
wcsstr
Synopsis
wchar_t *wcsstr(const wchar_t *s1,
const wchar_t *s2);
Description
wcsstr locates the first occurrence in the wide string pointed to by s1 of the sequence of wide characters
(excluding the terminating null wide character) in the wide string pointed to by s2.
wcsstr returns a pointer to the located wide string, or a null pointer if the wide string is not found. If s2 points to
a wide string with zero length, wcsstr returns s1.
758
wcstok
Synopsis
wchar_t *wcstok(wchar_t *s1,
const wchar_t *s2);
Description
wcstok A sequence of calls to wcstok breaks the wide string pointed to by s1 into a sequence of tokens, each of
which is delimited by a wide character from the wide string pointed to by s2. The first call in the sequence has a
non-null first argument; subsequent calls in the sequence have a null first argument. The separator wide string
pointed to by s2 may be different from call to call.
The first call in the sequence searches the wide string pointed to by s1 for the first wide character that is not
contained in the current separator wide string pointed to by s2. If no such wide character is found, then there are
no tokens in the wide string pointed to by s1 and wcstok returns a null pointer. If such a wide character is found,
it is the start of the first token.
wcstok then searches from there for a wide character that is contained in the current wide separator string. If
no such wide character is found, the current token extends to the end of the wide string pointed to by s1, and
subsequent searches for a token will return a null pointer. If such a wude character is found, it is overwritten by a
wide null character, which terminates the current token. wcstok saves a pointer to the following wide character,
from which the next search for a token will start.
Each subsequent call, with a null pointer as the value of the first argument, starts searching from the saved
pointer and behaves as described above.
Note
wcstok maintains static state and is therefore not reentrant and not thread safe. See wcstok_r for a thread-safe
and reentrant variant.
759
wcstok_r
Synopsis
wchar_t *wcstok_r(wchar_t *s1,
const wchar_t *s2,
wchar_t **s3);
Description
wcstok_r is a reentrant version of the function wcstok where the state is maintained in the object of type
wchar_t * pointed to by s3.
Note
wcstok_r is an extension commonly found in Linux and BSD C libraries.
See Also
wcstok.
760
wctob
Synopsis
int wctob(wint_t c);
Description
wctob determines whether c corresponds to a member of the extended character set whose multi-byte
character representation is a single byte when in the initial shift state in the current locale.
Description
this returns EOF if c does not correspond to a multi-byte character with length one in the initial shift state.
Otherwise, it returns the single-byte representation of that character as an unsigned char converted to an int.
761
wctob_l
Synopsis
int wctob_l(wint_t c,
locale_t loc);
Description
wctob_l determines whether c corresponds to a member of the extended character set whose multi-byte
character representation is a single byte when in the initial shift state in locale loc.
Description
wctob_l returns EOF if c does not correspond to a multi-byte character with length one in the initial shift state.
Otherwise, it returns the single-byte representation of that character as an unsigned char converted to an int.
762
wint_t
Synopsis
typedef long wint_t;
Description
wint_t is an integer type that is unchanged by default argument promotions that can hold any value
corresponding to members of the extended character set, as well as at least one value that does not correspond
to any member of the extended character set (WEOF).
763
wmemccpy
Synopsis
wchar_t *wmemccpy(wchar_t *s1,
const wchar_t *s2,
wchar_t c,
size_t n);
Description
wmemccpy copies at most n wide characters from the object pointed to by s2 into the object pointed to by s1.
The copying stops as soon as n wide characters are copied or the wide character c is copied into the destination
object pointed to by s1. The behavior of wmemccpy is undefined if copying takes place between objects that
overlap.
wmemccpy returns a pointer to the wide character immediately following c in s1, or NULL if c was not found in
the first n wide characters of s2.
Note
wmemccpy conforms to POSIX.1-2008.
764
wmemchr
Synopsis
wchar_t *wmemchr(const wchar_t *s,
wchar_t c,
size_t n);
Description
wmemchr locates the first occurrence of c in the initial n characters of the object pointed to by s. Unlike wcschr,
wmemchr does not terminate a search when a null wide character is found in the object pointed to by s.
wmemchr returns a pointer to the located wide character, or a null pointer if c does not occur in the object.
765
wmemcmp
Synopsis
int wmemcmp(const wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wmemcmp compares the first n wide characters of the object pointed to by s1 to the first n wide characters of
the object pointed to by s2. wmemcmp returns an integer greater than, equal to, or less than zero as the object
pointed to by s1 is greater than, equal to, or less than the object pointed to by s2.
766
wmemcpy
Synopsis
wchar_t *wmemcpy(wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wmemcpy copies n wide characters from the object pointed to by s2 into the object pointed to by s1. The
behavior of wmemcpy is undefined if copying takes place between objects that overlap.
wmemcpy returns the value of s1.
767
wmemmove
Synopsis
wchar_t *wmemmove(wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wmemmove copies n wide characters from the object pointed to by s2 into the object pointed to by s1 ensuring
that if s1 and s2 overlap, the copy works correctly. Copying takes place as if the n wide characters from the
object pointed to by s2 are first copied into a temporary array of n wide characters that does not overlap the
objects pointed to by s1 and s2, and then the n wide characters from the temporary array are copied into the
object pointed to by s1.
wmemmove returns the value of s1.
768
wmempcpy
Synopsis
wchar_t *wmempcpy(wchar_t *s1,
const wchar_t *s2,
size_t n);
Description
wmempcpy copies n wide characters from the object pointed to by s2 into the object pointed to by s1. The
behavior of wmempcpy is undefined if copying takes place between objects that overlap.
wmempcpy returns it returns a pointer to the wide character following the last written wide character.
Note
This is an extension found in GNU libc.
769
wmemset
Synopsis
wchar_t *wmemset(wchar_t *s,
wchar_t c,
size_t n);
Description
wmemset copies the value of c into each of the first n wide characters of the object pointed to by s.
wmemset returns the value of s.
770
wstrsep
Synopsis
wchar_t *wstrsep(wchar_t **stringp,
const wchar_t *delim);
Description
wstrsep locates, in the wide string referenced by *stringp, the first occurrence of any wide character in the wide
string delim (or the terminating wide null character) and replaces it with a wide null character. The location of
the next character after the delimiter wide character (or NULL, if the end of the string was reached) is stored in
*stringp. The original value of *stringp is returned.
An empty field (that is, a wide character in the string delim occurs as the first wide character of *stringp can be
detected by comparing the location referenced by the returned pointer to a wide null character.
If *stringp is initially null, wstrsep returns null.
Note
wstrsep is not an ISO C function, but appears in BSD4.4 and Linux.
771
<wctype.h>
API Summary
Classification functions
iswalnum
Is character alphanumeric?
iswalpha
Is character alphabetic?
iswblank
Is character blank?
iswcntrl
Is character a control?
iswctype
iswdigit
iswgraph
Is character a control?
iswlower
iswprint
Is character printable?
iswpunct
Is character punctuation?
iswspace
iswupper
iswxdigit
wctype
Conversion functions
towctrans
Translate character
towlower
towupper
wctrans
Is character alphanumeric?
iswalpha_l
Is character alphabetic?
iswblank_l
Is character blank?
iswcntrl_l
Is character a control?
iswctype_l
iswdigit_l
iswgraph_l
Is character a control?
iswlower_l
iswprint_l
Is character printable?
iswpunct_l
Is character punctuation?
772
iswspace_l
iswupper_l
iswxdigit_l
Translate character
towlower_l
towupper_l
wctrans_l
773
iswalnum
Synopsis
int iswalnum(wint_t c);
Description
iswalnum tests for any wide character for which iswalpha or iswdigit is true.
774
iswalnum_l
Synopsis
int iswalnum_l(wint_t c,
locale_t loc);
Description
iswalnum_l tests for any wide character for which iswalpha_l or iswdigit_l is true in the locale loc.
775
iswalpha
Synopsis
int iswalpha(wint_t c);
Description
iswalpha returns true if the wide character c is alphabetic. Any character for which iswupper or iswlower returns
true is considered alphabetic in addition to any of the locale-specific set of alphabetic characters for which none
of iswcntrl, iswdigit, iswpunct, or iswspace is true.
In the C locale, iswalpha returns nonzero (true) if and only if iswupper or iswlower return true for the value of
the argument c.
776
iswalpha_l
Synopsis
int iswalpha_l(wint_t c,
locale_t loc);
Description
iswalpha_l returns true if the wide character c is alphabetic in the locale loc. Any character for which iswupper_l
or iswlower_l returns true is considered alphabetic in addition to any of the locale-specific set of alphabetic
characters for which none of iswcntrl_l, iswdigit_l, iswpunct_l, or iswspace_l is true.
777
iswblank
Synopsis
int iswblank(wint_t c);
Description
iswblank tests for any wide character that is a standard blank wide character or is one of a locale-specific set of
wide characters for which iswspace is true and that is used to separate words within a line of text. The standard
blank wide are space and horizontal tab.
In the C locale, iswblank returns true only for the standard blank characters.
778
iswblank_l
Synopsis
int iswblank_l(wint_t c,
locale_t loc);
Description
iswblank_l tests for any wide character that is a standard blank wide character in the locale loc or is one of a
locale-specific set of wide characters for which iswspace_l is true and that is used to separate words within a line
of text. The standard blank wide are space and horizontal tab.
779
iswcntrl
Synopsis
int iswcntrl(wint_t c);
Description
iswcntrl tests for any wide character that is a control character.
780
iswcntrl_l
Synopsis
int iswcntrl_l(wint_t c,
locale_t loc);
Description
iswcntrl_l tests for any wide character that is a control character in the locale loc.
781
iswctype
Synopsis
int iswctype(wint_t c,
wctype_t t);
Description
iswctype determines whether the wide character c has the property described by t in the current locale.
782
iswctype_l
Synopsis
int iswctype_l(wint_t c,
wctype_t t,
locale_t loc);
Description
iswctype_l determines whether the wide character c has the property described by t in the locale loc.
783
iswdigit
Synopsis
int iswdigit(wint_t c);
Description
iswdigit tests for any wide character that corresponds to a decimal-digit character.
784
iswdigit_l
Synopsis
int iswdigit_l(wint_t c,
locale_t loc);
Description
iswdigit_l tests for any wide character that corresponds to a decimal-digit character in the locale loc.
785
iswgraph
Synopsis
int iswgraph(wint_t c);
Description
iswgraph tests for any wide character for which iswprint is true and iswspace is false.
786
iswgraph_l
Synopsis
int iswgraph_l(wint_t c,
locale_t loc);
Description
iswgraph_l tests for any wide character for which iswprint is true and iswspace is false in the locale loc.
787
iswlower
Synopsis
int iswlower(wint_t c);
Description
iswlower tests for any wide character that corresponds to a lowercase letter or is one of a locale-specific set of
wide characters for which none of iswcntrl, iswdigit, iswpunct, or iswspace is true.
788
iswlower_l
Synopsis
int iswlower_l(wint_t c,
locale_t loc);
Description
iswlower_l tests for any wide character that corresponds to a lowercase letter in the locale loc or is one of a
locale-specific set of wide characters for which none of iswcntrl_l, iswdigit_l, iswpunct_l, or iswspace_l is true.
789
iswprint
Synopsis
int iswprint(wint_t c);
Description
iswprint returns nonzero (true) if and only if the value of the argument c is any printing character.
790
iswprint_l
Synopsis
int iswprint_l(wint_t c,
locale_t loc);
Description
iswprint_l returns nonzero (true) if and only if the value of the argument c is any printing character in the locale
loc.
791
iswpunct
Synopsis
int iswpunct(wint_t c);
Description
iswpunct tests for any printing wide character that is one of a locale-specific set of punctuation wide characters
for which neither iswspace nor iswalnum is true.
792
iswpunct_l
Synopsis
int iswpunct_l(wint_t c,
locale_t loc);
Description
iswpunct_l tests for any printing wide character that is one of a locale-specific set of punctuation wide
characters in locale loc for which neither iswspace_l nor iswalnum_l is true.
793
iswspace
Synopsis
int iswspace(wint_t c);
Description
iswspace tests for any wide character that corresponds to a locale-specific set of white-space wide characters for
which none of iswalnum, iswgraph, or iswpunct is true.
794
iswspace_l
Synopsis
int iswspace_l(wint_t c,
locale_t loc);
Description
iswspace_l tests for any wide character that corresponds to a locale-specific set of white-space wide characters
in the locale loc for which none of iswalnum, iswgraph_l, or iswpunct_l is true.
795
iswupper
Synopsis
int iswupper(wint_t c);
Description
iswupper tests for any wide character that corresponds to an uppercase letter or is one of a locale-specific set of
wide characters for which none of iswcntrl, iswdigit, iswpunct, or iswspace is true.
796
iswupper_l
Synopsis
int iswupper_l(wint_t c,
locale_t loc);
Description
iswupper_l tests for any wide character that corresponds to an uppercase letter or is one of a locale-specific set
of wide characters in the locale loc for which none of iswcntrl_l, iswdigit_l, iswpunct_l, or iswspace_l is true.
797
iswxdigit
Synopsis
int iswxdigit(wint_t c);
Description
iswxdigit tests for any wide character that corresponds to a hexadecimal digit.
798
iswxdigit_l
Synopsis
int iswxdigit_l(wint_t c,
locale_t loc);
Description
iswxdigit_l tests for any wide character that corresponds to a hexadecimal digit in the locale loc.
799
towctrans
Synopsis
wint_t towctrans(wint_t c,
wctrans_t t);
Description
towctrans maps the wide character c using the mapping described by t in the current locale.
800
towctrans_l
Synopsis
wint_t towctrans_l(wint_t c,
wctrans_t t,
locale_t loc);
Description
towctrans_l maps the wide character c using the mapping described by t in the current locale.
801
towlower
Synopsis
wint_t towlower(wint_t c);
Description
towlower converts an uppercase letter to a corresponding lowercase letter.
If the argument c is a wide character for which iswupper is true and there are one or more corresponding wide
characters, in the current locale, for which iswlower is true, towlower returns one (and always the same one for
any given locale) of the corresponding wide characters; otherwise, c is returned unchanged.
802
towlower_l
Synopsis
wint_t towlower_l(wint_t c,
locale_t loc);
Description
towlower_l converts an uppercase letter to a corresponding lowercase letter in locale loc.
If the argument c is a wide character for which iswupper_l is true and there are one or more corresponding wide
characters, in the locale loc, for which iswlower_l is true, towlower_l returns one (and always the same one for
any given locale) of the corresponding wide characters; otherwise, c is returned unchanged.
803
towupper
Synopsis
wint_t towupper(wint_t c);
Description
towupper converts a lowercase letter to a corresponding uppercase letter.
If the argument c is a wide character for which iswlower is true and there are one or more corresponding wide
characters, in the current current locale, for which iswupper is true, towupper returns one (and always the same
one for any given locale) of the corresponding wide characters; otherwise, c is returned unchanged.
804
towupper_l
Synopsis
wint_t towupper_l(wint_t c,
locale_t loc);
Description
towupper_l converts a lowercase letter to a corresponding uppercase letter in locale loc.
If the argument c is a wide character for which iswlower_l is true and there are one or more corresponding wide
characters, in the locale loc, for which iswupper_l is true, towupper_l returns one (and always the same one for
any given locale) of the corresponding wide characters; otherwise, c is returned unchanged.
805
wctrans
Synopsis
wctrans_t wctrans(const char *property);
Description
wctrans constructs a value of type wctrans_t that describes a mapping between wide characters identified by
the string argument property.
If property identifies a valid mapping of wide characters in the current locale, wctrans returns a nonzero value
that is valid as the second argument to towctrans; otherwise, it returns zero.
Note
The only mappings supported are "tolower" and "toupper".
806
wctrans_l
Synopsis
wctrans_t wctrans_l(const char *property,
locale_t loc);
Description
wctrans_l constructs a value of type wctrans_t that describes a mapping between wide characters identified by
the string argument property in locale loc.
If property identifies a valid mapping of wide characters in the locale loc, wctrans_l returns a nonzero value that
is valid as the second argument to towctrans_l; otherwise, it returns zero.
Note
The only mappings supported are "tolower" and "toupper".
807
wctype
Synopsis
wctype_t wctype(const char *property);
Description
wctype constructs a value of type wctype_t that describes a class of wide characters identified by the string
argument property.
If property identifies a valid class of wide characters in the current locale, wctype returns a nonzero value that is
valid as the second argument to iswctype; otherwise, it returns zero.
Note
The only mappings supported are "alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower",
"print", "punct", "space", "upper", and "xdigit".
808
<xlocale.h>
API Summary
Functions
duplocale
freelocale
Free a locale
localeconv_l
newlocale
809
duplocale
Synopsis
locale_t duplocale(locale_t loc);
Description
duplocale duplicates the locale object referenced by loc.
If there is insufficient memory to duplicate loc, duplocale returns NULL and sets errno to ENOMEM as required
by POSIX.1-2008.
Duplicated locales must be freed with freelocale.
This is different behavior from the GNU glibc implementation which makes no mention of setting errno on
failure.
Note
This extension is derived from BSD, POSIX.1, and glibc.
810
freelocale
Synopsis
int freelocale(locale_t loc);
Description
freelocale frees the storage associated with loc.
freelocale zero on success, 1 on error.
811
localeconv_l
Synopsis
localeconv_l(locale_t loc);
Description
localeconv_l returns a pointer to a structure of type lconv with the corresponding values for the locale loc filled
in.
812
newlocale
Synopsis
locale_t newlocale(int category_mask,
const char *locale,
locale_t base);
Description
newlocale creates a new locale object or modifies an existing one. If the base argument is NULL, a new locale
object is created.
category_mask specifies the locale categories to be set or modified. Values for category_mask are constructed
by a bitwise-inclusive OR of the symbolic constants LC_CTYPE_MASK, LC_NUMERIC_MASK, LC_TIME_MASK,
LC_COLLATE_MASK, LC_MONETARY_MASK, and LC_MESSAGES_MASK.
For each category with the corresponding bit set in category_mask, the data from the locale named by locale
is used. In the case of modifying an existing locale object, the data from the locale named by locale replaces the
existing data within the locale object. If a completely new locale object is created, the data for all sections not
requested by category_mask are taken from the default locale.
The locales C and POSIX are equivalent and defined for all settings of category_mask:
If locale is NULL, then the C locale is used. If locale is an empty string, newlocale will use the default locale.
If base is NULL, the current locale is used. If base is LC_GLOBAL_LOCALE, the global locale is used.
If mask is LC_ALL_MASK, base is ignored.
Note
POSIX.1-2008 does not specify whether the locale object pointed to by base is modified or whether it is freed
and a new locale object created.
Implementation
The category mask LC_MESSAGES_MASK is not implemented as POSIX messages are not implemented.
813
814
Standard library
The following C++ standard header files are provided in $(StudioDir)/include:
File
Description
<cassert>
<cctype>
<cerrno>
<cfloat>
<ciso646>
<climits>
<clocale>
<cmath>
<csetjmp>
<cstdarg>
<cstddef>
<cstdio>
<cstdlib>
815
<cstring>
<ctime>
<cwchar>
<cwctype>
<exception>
<new>
<typeinfo>
It's worth mentioning again: to use exceptions or RTTI requires header files and or library code to be linked into
your application that is licensed under the GPL.
816
<bitset>
<deque>
<functional>
<hash_map>
<hash_set>
<iterator>
<limits>
<list>
<locale>
<map>
<memory>
<numeric>
<queue>
<set>
<stack>
<stdexcept>
<string>
<utility>
<valarray>
<vector>
817
818
Operators
operator delete
operator new
819
operator delete
Synopsis
void operator delete(void *ptr) throw();
void operator delete[](void *ptr) throw();
Description
operator delete deallocates space of an object.
operator delete will do nothing if ptr is null. If ptr is not null then it should have been returned from a call to
operator new.
operator delete[] has the same behaviour as operator delete but is used for array deallocation.
Portability
Standard C++.
820
operator new
Synopsis
void *operator new(size_t size) throw();
void *operator new[](size_t size) throw();
Description
operator new allocates space for an object whose size is specified by size and whose value is indeterminate.
operator new returns a null pointer if the space for the object cannot be allocated from free memory; if space for
the object can be allocated, operator new returns a pointer to the start of the allocated space.
operator new[] has the same behaviour as operator new but is used for array allocation.
Portability
The implementation is not standard. The standard C++ implementation should throw an exception if memory
allocation fails.
821
set_new_handler
Synopsis
typedef void (*new_handler)();
new_handler set_new_handler(new_handler) throw();
Description
set_new_handler establishes a new_handler function.
set_new_handler establishes a new_handler function that is called when operator new fails to allocate the
requested memory. If the new_handler function returns then operator new will attempt to allocate the memory
again. The new_handler function can throw an exception to implement standard C++ behaviour for memory
allocation failure.
Portability
Standard C++.
822
Utilities Reference
Utilities Reference
823
Utilities Reference
Compiler driver
This section describes the switches accepted by the compiler driver, cc. The compiler driver is capable of
controlling compilation by all supported language compilers and the final link by the linker. It can also construct
libraries automatically.
In contrast to many compilation and assembly language development systems, with you don't invoke the
assembler or compiler directly. Instead you'll normally use the compiler driver cc as it provides an easy way to
get files compiled, assembled, and linked. This section will introduce you to using the compiler driver to convert
your source files to object files, executables, or other formats.
We recommend that you use the compiler driver rather than use the assembler or compiler directly because
there the driver can assemble multiple files using one command line and can invoke the linker for you too. There
is no reason why you should not invoke the assembler or compiler directly yourself, but you'll find that typing in
all the required options is quite tedious-and why do that when cc will provide them for you automatically?
824
Utilities Reference
C language files
When the compiler driver finds a file with a .c extension, it runs the C compiler to convert it to object code.
825
Utilities Reference
Command-line options
This section describes the command-line options accepted by the SEGGER Embedded Studio compiler driver.
826
Utilities Reference
Description
Warn about potential problems that conflict with the relevant ANSI or ISO standard for the files that are
compiled.
827
Utilities Reference
Description
This switch instructs the compiler driver to archive all output files into a library. Using -ar implies -c.
Example
The following command compiles file1.c, file2.asm, and file3.c to object code and archives them into the library
file libfunc.a together with the object file file4.o.
cc -ar file1.c file2.asm file3.c file4.o -o libfunc.a
828
Utilities Reference
Description
Specifies the version of the instruction set to generate code for. The options are:
-arch=v4T ARM7TDMI and ARM920T
-arch=v5TE ARM9E, Feroceon and XScale
-arch=v6 ARM11
-arch=v6M Cortex-M0 and Cortex-M1
-arch=v7A Cortex-A8 and Cortex-A9
-arch=v7M Cortex-M3
-arch=v7EM Cortex-M4
-arch=v7R Cortex-R4
Example
To force compilation for V7A architecture you would use:
cc -arch=v7A
829
Utilities Reference
Description
Generate code for a big endian target.
830
Utilities Reference
Description
All named files are compiled to object code modules, but are not linked. You can use the -o option to name the
output if you just supply one input filename.
Example
The following command compiles file1.c and file4.c to produce the object files file1.o and file4.o.
cc -c file1.c file4.c
The following command compiles file1.c and produces the object file obj/file1.o.
cc -c file.c -o obj/file1.o
831
Utilities Reference
Description
You can define linker symbols using the -d option. The symbol definitions are passed to linker.
Example
The following defines the symbol, STACK_SIZE with a value of 512.
-dSTACK_SIZE=512
832
Utilities Reference
Description
You can define preprocessor macros using the -D option. The macro definitions are passed on to the respective
language compiler which is responsible for interpreting the definitions and providing them to the programmer
within the language.
The first form above defines the macro name but without an associated replacement value, and the second
defines the same macro with the replacement value value.
Example
The following defines two macros, SUPPORT_FLOAT with a value of 1 and LITTLE_ENDIAN with no replacement
value.
-DSUPPORT_FLOAT=1 -DLITTLE_ENDIAN
833
Utilities Reference
Description
Linker option to set the entry point symbol to be name. The debugger will start execution from this symbol.
834
Utilities Reference
-E (Preprocess)
Syntax
-E
Description
This option preprocesses the supplied file and outputs the result to the standard output.
Example
The following preprocesses the file file.c supplying the macros, SUPPORT_FLOAT with a value of 1 and
LITTLE_ENDIAN.
-E -DSUPPORT_FLOAT=1 -DLITTLE_ENDIAN file.c
835
Utilities Reference
Description
Enables C++ exceptions to be compiled.
836
Utilities Reference
Description
Specifies the type of floating point code generation. The options are:
-fabi=SoftFP FPU instructions are generated, CPU registers are used for floating point parameters.
-fabi=Hard FPU instructions are generated, FPU registers are used for floating point parameters.
837
Utilities Reference
Description
Specifies the floating point unit to generate code for when the fpabi option has been supplied. The options are:
-fpu=VFP generate FPU instructions for ARM9 and ARM11
-fpu=VFPv3-D32 generate FPU instructions for CortexA
-fpu=VFPv3-D16 generate FPU instructions for CortexR
-fpu=FPv4-SP-D16 generate FPU instructions for CortexM4
838
Utilities Reference
Description
The -F option instructs the compiler driver to generate an additional output file in the format fmt. The compiler
driver supports the following formats:
-Fbin Create a .bin file
-Fhex Create a .hex file
-Fsrec Create a .srec file
The compiler driver will always output a .elf file as specified with the -o option. The name of the additional
output file is the same as the .elf file with the file extension changed.
For example
cc file.c -o file.elf -Fbin
839
Utilities Reference
Description
The -g option instructs the compiler and assembler to generate source level debugging information for the
debugger to use.
840
Utilities Reference
Description
The -g1 option instructs the compiler to generate debugging information that enables the debugger to be able
to backtrace only.
841
Utilities Reference
Description
Displays a short summary of the options accepted by the compiler driver.
842
Utilities Reference
Description
This option specifies the I/O library implementation that is included in the linked image. The options are:
-io=d I/O library is implemented using debugIO e.g calls to printf will call debug_printf.
-io=t I/O library is implemented on the target, debugIO is not used.
-io=t+d I/O library is implemented on the target, debugIO is not used but debugIO is enabled.
843
Utilities Reference
Description
In order to find include files the compiler driver arranges for the compilers to search a number of standard
directories. You can add directories to the search path using the -I switch which is passed on to each of the
language processors.
You can specify more than one include directory by separating each directory component with either a comma
or semicolon.
844
Utilities Reference
Description
Usually the compiler and assembler search for include files in the standard include directory created when the
product is installed. If for some reason you wish to exclude these system locations from being searched when
compiling a file, the -I- option will do this for you.
845
Utilities Reference
Description
The -J option adds directory to the end of the list of directories to search for source files included (using
triangular brackets) by the #include preprocessor command.
You can specify more than one include directory by separating each directory component with either a comma
or semicolon in the property
846
Utilities Reference
Description
The linker removes unused code and data from the output file. This process is called deadstripping. To prevent
the linker from deadstripping unreferenced code and data you wish to keep, you must use the -K command line
option to force inclusion of symbols.
Example
If you have a C function, contextSwitch that must be kept in the output file (and which the linker will normally
remove), you can force its inclusion using:
-KcontextSwitch
847
Utilities Reference
Description
Sets the library directory to dir. If -L is not specified on the command line, the default location to search for
libraries is set to $(InstallDir)/lib.
848
Utilities Reference
Description
The -l option instructs the compiler driver not to link standard libraries. If you use this option you must supply
your own library functions or libraries.
849
Utilities Reference
Description
The -make option avoids build steps based on the modification date of the output file and modification date of
the input file and its dependencies.
850
Utilities Reference
Description
The -M option prints a linkage map named the same as the linker output file with the .map file extension.
851
Utilities Reference
Description
When -n is specified, the compiler driver processes options as usual, but does not execute any subprocesses to
compile, assemble, archive or link applications.
852
Utilities Reference
Description
When -nostderr is specified, any stderr output of subprocesses is redirected to stdout.
853
Utilities Reference
Description
The -o option instructs the compiler driver to write linker or archiver output to filename.
854
Utilities Reference
Description
The -oabi option instructs the compiler driver to generate code and link libraries for the legacy GCC ARM ABI.
855
Utilities Reference
-O (Optimize output)
Syntax
-Ox
Description
Pass the optimization option -Ox to the compiler and select library variant. The following options are supported:
-O0 No optimization, use libraries built with -O1.
-O1 Level 1 optimization, use libraries built with -O1.
-O2 Level 2 optimization, use libraries built with -O1.
-O3 Level 3 optimization, use libraries built with -O1.
-Os Optimize for size, use libraries built with -Os.
856
Utilities Reference
Description
The -printf option selects the printf capability for the linked executable. The options are:
-printf=i integer is supported
-printf=li long integer is supported
-printf=ll long long integer is supported
-printf=f floating point is supported
-printf=wp width and precision is supported
857
Utilities Reference
Description
Enables C++ run-time type information to be compiled.
858
Utilities Reference
Description
These options name the default name of the sections generated by the compiler/assembler to be name. The
options are:
-Rc name change the default name of the code section
-Rd name change the default name of the data section
-Rk name change the default name of the const section
-Rz name change the default name of the bss section
859
Utilities Reference
Description
The -scanf option selects the scanf capability for the linked executable. The options are:
-scanf=i integer is supported
-scanf=li long integer is supported
-scanf=ll long long integer is supported
-scanf=f floating point is supported
-scanf=wp %[...] and %[^...] character class is supported
860
Utilities Reference
Description
The -sd option instructs the compiler to compile double as float and selects the appropriate library for linking.
861
Utilities Reference
Description
The -Thumb option instructs the compiler to generate Thumb code rather than ARM code and link in Thumb
libraries. This option is NOT needed for Cortex-M architectures.
862
Utilities Reference
-v (Verbose execution)
Syntax
-v
Description
The -v switch displays command lines executed by the compiler driver.
863
Utilities Reference
-w (Suppress warnings)
Syntax
-w
Description
This option instructs the compiler, assembler, and linker not to issue any warnings.
864
Utilities Reference
Description
This option directs the compiler, assembler, and linker to treat all warnings as errors.
865
Utilities Reference
Description
The -W command-line option passes option directly to the specified tool. Supported tools are
-Wa pass option to assembler
-Wc pass option to compiler
-Wl pass option to linker
Example
The following example passes the (compiler specific) -version option to the compiler
cc -Wc-version
866
Utilities Reference
Description
The -x option causes the compiler driver to treat subsequent files to be of the following file type
-xa archives/libraries
-xasm assembly code files
-xc C code files
-xc++ C++ code files
-xld linker script files
-xo object code files
Example
The following command line enables an assembly code file with the extension .arm to be assembled.
cc -xasm a.arm
867
Utilities Reference
Description
If required this option must be the first option on the command line. It instantiates a project template type
from the installed packages. The files and common project properties of the project template are used by the
compiler driver. Project configurations are not supported by the compiler driver, use emBuild if you require
project configurations.
Example
The following command builds an executable based on the STM32_EXE project template.
cc -ySTM32_EXE -zTarget=STM32F100C4 file.c -o file.elf
868
Utilities Reference
Description
Sets the value of the project property p to the value v.
Example
The following command compiles the file arguments and puts the resulting object files into the directory
objects.
cc -c file1.c file2.c -zbuild_output_directory=objects
869
Utilities Reference
870
Utilities Reference
Syntax
emBuild [options] project-file
You must specify a configuration to build using -config. For instance:
emBuild -config "V5T Thumb LE Release" arm.emProject
The above example uses the configuration V5T Thumb LE Release to build all projects in the solution contained
in arm.emProject.
To build a specific project that is in a solution, you can specify it using the -project option. For example:
emBuild -config "V5T Thumb LE Release" -project "libm" libc.emProject
This example will use the configuration V5T Thumb LE Release to build the project libm that is contained in
libc.emProject.
If your project file imports other project files (using the <import> mechanism), when denoting projects you
must specify the solution names as a comma-separated list in parentheses after the project name:
emBuild -config "V5T Thumb LE Release" -project "libc(C Library)" arm.emProject
libc(C Library) specifies the libc project in the C Library solution that has been imported by the project file
arm.emProject.
To build a specific solution that has been imported from other project files, you can use the -solution option.
This option takes the solution names as a comma-separated list. For example:
emBuild -config "ARM Debug" -solution "ARM Targets,EB55" arm.emProject
In this example, ARM Targets,EB55 specifies the EB55 solution imported by the ARM Targets solution, which
was itself imported by the project file arm.emProject.
You can do a batch build using the -batch option:
emBuild -config "ARM Debug" -batch libc.emProject
This will build the projects in libc.emProject that are marked for batch build in the configuration ARM Debug.
By default, a make-style build will be donei.e., the dates of input files are checked against the dates of output
files, and the build is avoided if the output is up to date. You can force a complete build by using the -rebuild
option. Alternatively, to remove all output files, use the -clean option.
871
Utilities Reference
To see the commands being used in the build, use the -echo option. To also see why commands are being
executed, use the -verbose option. You can see what commands will be executed, without executing them, by
using the -show option.
872
Utilities Reference
873
Utilities Reference
Command-line options
This section describes the command-line options accepted by emBuild.
874
Utilities Reference
Description
Perform a batch build.
875
Utilities Reference
Description
Specify the configuration for a build. If the configuration name can't be found, emBuild will list the available
configurations.
876
Utilities Reference
Description
Remove all output files resulting from the build process.
877
Utilities Reference
Description
Define a SEGGER Embedded Studio macro value for the build process.
878
Utilities Reference
Description
Show the command lines as they are executed.
879
Utilities Reference
Description
Build the file name. Use with -template or -type.
880
Utilities Reference
Description
Override the default value of the $(PackagesDir) macro.
881
Utilities Reference
Description
Specify the name of the project to build. When used with a project file, if emBuild can't find the specified project,
the names of available projects are listed.
882
Utilities Reference
Description
Specify the value of a project property use with -template or -type. If emBuild cannot find the specified
property, a list of the properties is shown.
883
Utilities Reference
Description
Always execute the build commands.
884
Utilities Reference
Description
Show the command lines that would be executed, but do not execute them.
885
Utilities Reference
Description
Specify the name of the solution to build. If emBuild cannot find the given solution, the valid solution names are
listed.
886
Utilities Reference
Description
Override the default value of the $(StudioDir) macro.
887
Utilities Reference
Description
Specify the project template to use. If emBuild cannot find the specified template then a list of template names
is shown.
888
Utilities Reference
Description
Specify the project type to use. If emBuild cannot find the specified project type then a list of project type names
is shown.
889
Utilities Reference
Description
Show extra information relating to the build process.
890
Utilities Reference
Command-Line Scripting
emScript is a program that allows you to run SEGGER Embedded Studio's JavaScript (ECMAScript) interpreter
from the command line.
The primary purpose of emScript is to facilitate the creation of platform-independent build scripts.
Syntax
emScript [options] file
891
Utilities Reference
Command-line options
This section describes the command-line options accepted by emScript.
892
Utilities Reference
Description
893
Utilities Reference
Description
Display usage information and command line options.
894
Utilities Reference
Description
Loads the script file path.
895
Utilities Reference
Description
Produces verbose output.
896
Utilities Reference
emScript classes
emScript provides the following predefined classes:
BinaryFile
CWSys
ElfFile
WScript
897
Utilities Reference
Example uses
The following example demonstrates using emScript to increment a build number:
First, add a JavaScript file to your project called incbuild.js containing the following code:
function incbuild()
{
var file = "buildnum.h"
var text = "#define BUILDNUMBER "
var s = CWSys.readStringFromFile(file);
var n;
if (s == undefined)
n = 1;
else
n = eval(s.substring(text.length)) + 1;
CWSys.writeStringToFile(file, text + n);
}
// Executed when script loaded.
incbuild();
Add a file called getbuildnum.h to your project containing the following code:
#ifndef GETBUILDNUM_H
#define GETBUILDNUM_H
unsigned getBuildNumber();
#endif
Add a file called getbuildnum.c to your project containing the following code:
#include "getbuildnum.h"
#include "buildnum.h"
unsigned getBuildNumber()
{
return BUILDNUMBER;
}
898
Utilities Reference
Embed
Embed is a program that converts a binary file into a C/C++ array definition.
The primary purpose of the Embed tool is to provide a simple method of embedding files into an application.
This may be useful if you want to include firmware images, bitmaps, etc. in your application without having to
read them first from an external source.
Syntax
embed variable_name input_file output_file
variable_name is the name of the C/C++ array to be initialised with the binary data.
input_file is the path to the binary input file.
output_file is the path to the C/C++ source file to generate.
Example
To convert a binary file image.bin to a C/C++ file called image.h:
embed img image.bin image.h
0x2D,
0x31,
0x22,
0x54,
0x57,
0x2C,
0x59,
0x05,
0x47,
0x66,
0x37,
0xA4,
0x05,
0x39,
0x9F,
0xBF
899
Utilities Reference
900
Utilities Reference
We can generate the header file associated with this file using:
mkhdr memorymap.xml memorymap.h
Writing a register
AIC_SMR0 = (priority << AIC_SMR0_PRIOR_BIT) | (srctype << AIC_SMR0_SRCTYPE_BIT);
Reading a bitfield
unsigned srctype = (AIC_SMR0 & AIC_SMR0_SRCTYPE_MASK) >> AIC_SMR0_SRCTYPE_BIT;
Writing a bitfield
901
Utilities Reference
Syntax
mkhdr inputfile outputfile targetname [option]
inputfile is the name of the source SEGGER Embedded Studio memory map file. outputfile is the the name of
the file to write.
902
Utilities Reference
Description
Instructs the header generator to include offsets of registers from the peripheral base.
903
Utilities Reference
Description
Instructs the header generator not to generate any definitions for bitfields.
904
Utilities Reference
Syntax
mkld -memory-map-file inputfile outputfile [options]
inputfile is the name of the SEGGER Embedded Studio memory map file to generate the ld script from.
outputfile is the the name of the ld script file to write.
905
Utilities Reference
Command-line options
This section describes the command-line options accepted by mkld.
906
Utilities Reference
-check-segment-overflow
Syntax
-check-segment-overflow
Description
Add checks for memory segment overflow to the linker script.
907
Utilities Reference
-memory-map-file
Syntax
-memory-map-file filename
Description
Generate a GNU ld linker script from the SEGGER Embedded Studio memory map file filename.
908
Utilities Reference
-memory-map-macros
Syntax
-memory-map-macros macro=value[;macro=value]
Description
Define SEGGER Embedded Studio macros to use when reading a memory map file.
909
Utilities Reference
-section-placement-file
Syntax
-section-placement-file filename
Description
Generate a GNU ld linker script from the SEGGER Embedded Studio section placement file filename. If this option
is used, a memory map file should also be specified with the -memory-map-file option.
910
Utilities Reference
-section-placement-macros
Syntax
-section-placement-macros macro=value[;macro=value]
Description
Define SEGGER Embedded Studio macros to use when reading a section placement file.
911
Utilities Reference
-symbols
Syntax
-symbols symbol=value[;symbol=value]
Description
Add extra symbol definitions to the ld linker script.
912
Utilities Reference
Package generator
To create a package the program mkpkg can be used. The set of files to put into the package should be
in the desired location in the $(PackagesDir) directory. The mkpkg command should be run with
$(PackagesDir) as the working directory and all files to go into the package must be referred to using
relative paths. A package must have a package description file that is placed in the $(PackagesDir)/
packages directory. The package description file name must end with _package.xml. If a package is to
create entries in the new project wizard then it must have a file name project_templates.xml.
For example, a package for the mythical FX150 processor would supply the following files:
A project template file called targets/FX150/project_templates.xml. The format of the
project templates file is described in Project Templates file format.
The $(PackagesDir)-relative files that define the functionality of the package.
A package description file called packages/FX150_package.xml. The format of the package
description file is described in Package Description file format.
The package file FX150.emPackage would be created using the following command line:
mkpkg -c packages/FX150.emPackage targets/FX150/project_templates.xml packages/
FX150_package.xml
You can list the contents of the package using the -t option:
mkpkg -t packages/FX150.emPackage
You can add or replace a file into an existing package using the -r option:
mkpkg -r packages/FX150.emPackage -r fileName
You can extract files from an existing package using the -x option:
mkpkg -x packages/FX150.emPackage outputDirectory
You can automate the package creation process using a Combining project type.
Using the new project wizard create a combining project in the directory $(PackagesDir).
Set the Output File Path property to be $(PackagesDir)/packages/mypackage.emPackage.
Set the Combine command property to $(StudioDir)/bin/mkpkg -c $(CombiningOutputFilePath)
$(CombiningRelInputPaths).
Add the files you want to go into the package into the project using the Project Explorer.
Right-click the project node in the Project Explorer and choose Build.
When a package is installed, the files in the package are copied into the desired $(PackagesDir)-relative
locations. When a file is copied into the $(PackagesDir)/packages directory and its filename ends with
913
Utilities Reference
During development of a package you can manually edit this file. The same applies to the file
$(PackagesDir)/targets/project_templates.xml which will contain a reference to your
project_templates.xml file.
Usage:
mkpkg [options] packageFileName file1 file2
Option
Description
-c
-compress level
-d
-f
-r
-readonly
-t
-v
Be chatty.
-V
-x
914
Appendices
Appendices
915
Appendices
File formats
This section describes the file formats SEGGER Embedded Studio uses:
916
Appendices
The next entry is the Root element. There can only be one Root element in a memory map file:
<Root name="My Board">
A Root element has a name attribute every element in a memory map file has a name attribute. Names
should be unique within a hierarchy level. Within a Root element, there are MemorySegment elements that
represent regions within the memory map.
<Root name="My Board">
<MemorySegment name="Flash" start="0x1000" size="0x200" access="ReadOnly">
RegisterGroup elements have the same attributes as MemorySegment elements. Register elements
have the following attributes:
name: Register names should be valid C/C++ identifier names, i.e., alphanumeric characters and
underscores are allowed but names cannot start with a number.
start: The start address of the memory segment. Either a C-style hexadecimal number or, if given a +
prefix, an offset from the enclosing element's start address.
917
Appendices
You can import CMSIS SVD files (see http://www.onarm.com/) into a memory map using the ImportSVD
element:
<ImportSVD filename="$(TargetsDir)/targets/Manufacturer1/Processor1.svd.xml">
The filename attribute is an absolute filename which is macro-expanded using SEGGER Embedded Studio
system macros.
When a memory map file is loaded either for the memory map viewer or to be used for linking or debugging, it is
preprocessed using the (as yet undocumented) SEGGER Embedded Studio XML preprocessor.
918
Appendices
The next entry is the Root element. There can only be one Root element in a memory map file:
<Root name="Flash Placement">
A Root element has a name attribute. Every element in a section-placement file has a name attribute. Each
name should be unique within its hierarchy level. Within a Root element, there are MemorySegment elements.
These correspond to memory regions defined in a memory map file that will be used in conjunction with the
section-placement file when linking a program. For example:
<Root name="Flash Placement">
<MemorySegment name="FLASH">
A MemorySegment contains ProgramSection elements that represent program sections created by the C/
C++ compiler and assembler. The order of ProgramSection elements within a MemorySegment element
represents the order in which the sections will be placed when linking a program. The first ProgramSection
will be placed first and the last one will be placed last.
<Root name="My Board" >
<MemorySegment name="FLASH">
<ProgramSection name=".text">
919
Appendices
runin: This specifies the name of the section to copy this section to.
runoffset: This specifies an offset from the load address that the section will be run from.
size: The optional size of the program section in bytes, a hexadecimal number with a 0x prefix.
size_symbol: A symbolic name for the size of the section.
start: The optional start address of the program section, a hexadecimal number with a 0x prefix.
When a section placement file is used for linking it is preprocessed using the (as yet undocumented) SEGGER
Embedded Studio XML preprocessor.
920
Appendices
The next entry is the solution element; there can only be one solution element in a project file. This
specifies the solution name displayed in the Project Explorer and has a version attribute that defines the fileformat version of the project file. Solutions can contain projects, projects can contain folders and files, and
folders can contain folders and files. This hierarchy is reflected in the XML nestingfor example:
<solution version="1" Name="solutionname">
<project Name="projectname">
<file Name="filename" />
<folder Name="foldername">
<file Name="filename2" />
</folder>
</project>
</solution>
Note that each entry has a Name attribute. Names of project elements must be unique to the solution, and
names of folder elements must be unique to the project, but names of files do not need to unique.
Each file element must have a file_name attribute that is unique to the project. Ideally, the file_name
is a file path relative to the project (or solution directory), but you can also specify a full file path, if you want to.
File paths are case-sensitive and use "/" as the directory separator. They may contain macro instantiations, so file
paths cannot contain the "$" character. For example
<file file_name="$(StudioDir)/source/crt0.s" Name="crt0.s" />
will be expanded using the value of $(StudioDir) when the file is referenced from SEGGER Embedded Studio.
Project properties are held in configuration elements with the Name attribute of the configuration element
corresponding to the configuration name, e.g., "Debug". At a given project level (i.e., solution, project, folder),
there can only be one named configuration elementi.e., all properties defined for a configuration are in single
configuration element.
<project Name="projectname">
?
<configuration project_type="Library" Name="Common" />
<configuration Name="Release" build_debug_information="No" />
?
</project>
921
Appendices
The next entry is the projects element, which is used to group a set of new project entries into an XML
hierarchy.
<projects>
<project>
</projects>
Each entry has a project element that contains the class of the project (attribute caption), the name of the
project (attribute name), its type (attribute type) and a description (attribute description). For example:
<project caption="ARM Evaluator7T" name="Executable"
description="An executable for an ARM Evaluator7T." type="Executable"/>
The property values to be created for the project are defined using the property element. If you have a
defined value, you can specify this using the value attribute and, optionally, set the property in a defined
configuration, such as:
<property name="target_reset_script" configuration="RAM"
value="Evaluator7T_ResetWithRamAtZero()" />
Alternatively, you can include a property that will be shown to the user, prompting them to supply a value as
part of the new-project process.
<property name="linker_output_format"/>
922
Appendices
The folders to be created are defined using the folder element. The folder element must have a name
attribute and can also have a filter attribute. For example:
<folder name="Source Files" filter="c;cpp;cxx;cc;h;s;asm;inc" />
The files to be in the project are specified using the file element. You can use build-system macros (see
Project macros) to specify files located in the SEGGER Embedded Studio installation directory. Files will be
copied to the project directory or just left as references, depending on the value of the expand attribute:
<file name="$(StudioDir)/source/crt0.s" expand="no"/>
You can define the set of configurations that can be referred to in the top-level configurations element:
<configurations>
<configuration>
</configurations>
This contains the set of all configurations that can be created when a project is created. Each configuration is
defined using a configuration element, which can define the property values for that configuration. For
example:
<configuration name="Debug">
<property name="build_debug_information" value="Yes">
923
Appendices
The next entry is the propertyGroups element, which is used to group a set of property groups entries into
an XML hierarchy:
<propertyGroups>
<grouphdots
?
<grouphdots
</propertyGroups>
Each group has the name of the group (attribute name), the name of the options category (attribute group),
short (attribute short) and long (attribute long) help descriptions, and a default value (attribute default).
For example:
<group short="Target Processor" group="Build Options" short="Target Processor"
long="Select a set of target options" name="Target" default="STR912FW44" />
Each group has a number of groupEntry elements that define the enumerations of the group.
<group\>
<groupEntry>
<groupEntry>
</group>
Each groupEntry has the name of the entry (attribute name), e.g.:
<groupEntry name="STR910FW32">
A groupEntry has the property values and C pre-processor definitions that are set when the groupEntry is
selected; they are specified with property and cdefine elements. For example:
<groupEntry>
<property>
924
Appendices
<cdefine>
<property>
</groupEntry>
A property element has the property's name (attribute name), its value (attribute value), and an optional
configuration (attribute configuration):
<property name="linker_memory_map_file"
value="$(StudioDir)/targets/ST_STR91x/ST_STR910FM32_MemoryMap.xml" />
A cdefine element has the C preprocessor name (attribute name) and its value (attribute value):
<cdefine value="STR910FM32" name="TARGET_PROCESSOR" />
925
Appendices
Philips_LPC2000_package.xml
<!DOCTYPE CrossStudio_Package_Description_File>
<package cpu_manufacturer="Philips" cpu_family="LPC2000" version="1.1" ses_versions="8:1-"
author="SEGGER" >
<file file_name="$(TargetsDir)/Philips_LPC210X/arm_target_Philips_LPC210X.htm"
title="LPC2000 Support Package Documentation" />
<file file_name="$(TargetsDir)/Philips_LPC210X/Loader.emProject" title="LPC2000 Loader
Application Solution" />
<group title="System Files">
<file file_name="$(TargetsDir)/Philips_LPC210X/Philips_LPC210X_Startup.s" title="LPC2000
Startup Code" />
<file file_name="$(TargetsDir)/Philips_LPC210X/Philips_LPC210X_Target.js" title="LPC2000
Target Script" />
</group>
<history>
<version name="1.1" >
<description>Corrected LPC21xx header files and memory maps to include GPIO ports 2
and 3.</description>
<description>Modified loader memory map so that .libmem sections will be placed
correctly.</description>
</version>
<version name="1.0" >
<description>Initial Release.</description>
</version>
</history>
<documentation>
<section name="Supported Targets">
<p>This CPU support package supports the following LPC2000 targets:
<ul>
<li>LPC2103</li>
<li>LPC2104</li>
<li>LPC2105</li>
<li>LPC2106</li>
<li>LPC2131</li>
<li>LPC2132</li>
<li>LPC2134</li>
<li>LPC2136</li>
<li>LPC2138</li>
</ul>
</p>
</section>
926
Appendices
</documentation>
</package>
CrossFire_LPC2138_package.xml
<!DOCTYPE CrossStudio_Package_Description_File>
<package cpu_manufacturer="Philips" cpu_family="LPC2000" cpu_name="LPC2138"
board_manufacturer="Rowley Associates" board_name="CrossFire LPC2138"
dependencies="Philips_LPC2000" version="1.0">
<file file_name="$(SamplesDir)/CrossFire_LPC2138/CrossFire_LPC2138.emProject"
title="CrossFire LPC2138 Samples Solution" />
<file file_name="$(SamplesDir)/CrossFire_LPC2138/ctl/ctl.emProject" title="CrossFire
LPC2138 CTL Samples Solution" />
</package>
Package elements
The package element describes the support package, its contents, and any dependencies it has on other
packages. Valid attributes for this element are:
Attribute
Description
author
board_manufacturer
board_name
cpu_family
cpu_manufacturer
cpu_name
ses_versions
description
dependencies
installation_directory
title
927
version
Appendices
File elements
The file element is used by SEGGER Embedded Studio for documentation purposes by adding links to files of
interest within the package such as example project files and documentation.
Attribute
Description
file_name
title
Optionally, file elements can be grouped into categories using the group element.
Group elements
The group element is used for categorizing files described by file elements into a particular group.
Attribute
Description
title
History elements
The history element is used to hold a description of the package's version history.
The history element should contain a collection of version elements.
Version element
The version element is used to hold the description of a particular version of the package.
Attribute
Description
name
Description elements
Each description element contains text that describes a feature of the package version.
928
Appendices
Documentation elements
The documentation element is used to provide arbitrary documentation for the package.
The documentation element should contain a collection of one or more section elements.
Section elements
The section element contains package documentation in XHTML format.
Attribute
Description
name
target_id_number
The following table lists the possible target ID numbers:
Target
ID
AVR
ARM
MSP430
MAXQ20
18
MAXQ30
19
version_range_string
The version_range_string can be any of the following:
version_number: The package will only work on version_number.
version_number-: The package will work on version_number or any future version.
-version_number: The package will work on version_number or any earlier version.
low_version_number-high_version_number: The package will work on low_version_number,
high_version_number or any version in between.
929
Appendices
Structure
All tools are wrapped in a tools element:
<tools>
?
</tools>
Inside the tools element are item elements that define each tool:
<tools>
<item name="logical name">
?
</item>
</tools>
The item element requires an name attribute, which is an internal name for the tool, and has an optional wait
element. When SEGGER Embedded Studio invokes the tool on a file or project, it uses the wait element to
determine whether it should wait for the external tool to complete before continuing. If the wait attribute is not
provided or is set to yes, SEGGER Embedded Studio will wait for external tool to complete.
The way that the tool is presented in SEGGER Embedded Studio is configured by elements inside the
element.
menu
The menu element defines the wording used inside menus. You can place a shortcut to the menu using an
ampersand, which must be escaped using & in XML, before the shortcut letter. For instance:
<menu>&PC-lint (Unit Check)</menu>
text
The optional text element defines the wording used in contexts other than menus, for instance when the tool
appears as a tool button with a label. If text is not provided, the tool's textual appearance outside the menu is
taken from the menu element (and is presented without an shortcut underline). For instance:
930
Appendices
tip
The optional tip element defines the status tip, shown on the status line, when moving over the tool inside
SEGGER Embedded Studio:
<tip>Run a PC-lint unit checkout on the selected file or folder</tip>
key
The optional key element defines the accelerator key, or key chord, to use to invoke the tool using the keyboard.
You can construct the key sequence using modifiers Ctrl, Shift, and Alt, and can specify more than one key in a
sequence (note: Windows and Linux only; OS X does not provide key chords). For instance:
<key>Ctrl+L, Ctrl+I</key>
message
The optional message element defines the text shown in the tool log in SEGGER Embedded Studio when
running the tool. For example:
<message>Linting</message>
match
The optional match element defines which documents the tool will operator on. The match is performed using
the file extension of the document. If the file extension of the document matches one of the wildcards provided,
the tool will run on that document. If there is no match element, the tool will run on all documents. For instance:
<match>*.c;*.cpp</match>
commands
The commands element defines the command line to run to invoke the tool. The command line is expanded
using macros applicable to the file derived from the current build configuration and the project settings. Most
importantly, the standard $(InputPath) macro expands to a full pathname for the target file.
Additional macros constructed by SEGGER Embedded Studio are:
$(DEFINES) is the set of -D options applicable to the current file, derived from the current configuration
and project settings.
$(INCLUDES) is the set of -I options applicable to the current file, derived from the current configuration
and project settings.
For instance:
931
Appendices
<commands>
"$(LINTDIR)/lint-nt" -i$(LINTDIR)/lnt "$(LINTDIR)/lnt/co-gcc.lnt"
$(DEFINES) $(INCLUDES) -D__GNUC__ -u -b +macros -w2 -e537 +fie +ffn -width(0,4) -hF1
"-format=%f:%l:%C:s%t:s%m" "$(InputPath)"
</commands>
In this example we intend $(LINTDIR) to point to the directly where PC-lint is installed and for $(LINTDIR) to be
defined as a SEGGER Embedded Studio global macro. You can set global macros using Project > Macros.
Note that additional " entities are placed around pathnames in the commands sectionthis is to ensure
that paths that contain spaces are correctly interpreted when the command is executed by SEGGER Embedded
Studio.
932
Appendices
Description
Always Rebuild
build_always_rebuild Boolean
project_dependencies_can_build_in_parallel parallel.
Boolean
Build Quietly
build_quietly Boolean
Intermediate Directory
build_intermediate_directory DirPath
Output Directory
build_output_directory DirPath
Project Dependencies
project_dependencies StringList
Project Directory
project_directory String
Project Macros
macros StringList
933
Project Type
project_type Enumeration
Suppress Warnings
build_suppress_warnings Boolean
Appendices
General Options
Property
Description
Inherited Configurations
inherited_configurations StringList
Package Options
Property
Description
Package Dependencies
package_dependencies StringList
934
Appendices
Combine Command
combine_command String
Set To Read-only
combine_set_readonly Enumeration
Description
The command to execute. This property will have
macro expansion applied to it with the macro <b>
$(CombiningOutputFilePath)</b> set to the output
filepath of the combine command and the macro <b>
$(CombiningRelInputPaths)</b> is set to the (project
relative) names of all of the files in the project.
The working directory in which the combine command
is run. This property will have macro expansion applied
to it.
The output file path the stage command will create.
This property will have macro expansion applied to it.
Set the output file to read only or read/write.
935
Appendices
Compilation Properties
Assembler Options
Property
Additional Assembler Options
asm_additional_options StringList
Description
Enables additional options to be supplied to the
assembler. This property will have macro expansion
applied to it.
Assembler
arm_assembler_variant Enumeration
ARM Architecture
arm_architecture Enumeration
Description
Specifies the version of the instruction set to
generate code for. The options are:<ul><li>v6M Cortex-M0 and Cortex-M1 processors</li><li>v7M
- Cortex-M3 processors</li><li>v7EM - Cortex-M4
processors</li></ul>The corresponding preprocessor
definitions:<ul><li>__ARM_ARCH_6M__</
li><li>__ARM_ARCH_7M__</
li><li>__ARM_ARCH_7EM__</li></ul> are defined.
Specifies the core to generate code for. The options
are:<ul><li>Cortex-M0, Cortex-M0+, Cortex-M1,
Cortex-M3, Cortex-M4, Cortex-M7</li><li>None</li></
ul>If this property is set to None then the architecture
setting is used
Specifies the FP ABI type to generate code for.
The options are:<ul><li><b>Soft</b> generate
calls to the C library to implement floating point
operations.</li><li><b>SoftFP</b> generate VFP
code to implement floating point operations.</
li><li><b>Hard</b> generate VFP code to implement
floating point operations and use VFP registers to
pass floating point parameters on function calls.</
li><li><b>None</b> will not specify the FP ABI or the
FPU.</li></ul>
936
Byte Order
arm_endian Enumeration
Debugging Level
gcc_debugging_level Enumeration
Dwarf Version
gcc_dwarf_version Enumeration
Enumeration Size
gcc_short_enum Enumeration
Instruction Set
arm_instruction_set Enumeration
Instrument Functions
arm_instrument_functions Boolean
Long Calls
arm_long_calls Boolean
No COMMON
gcc_no_common Boolean
Appendices
937
Optimization Level
gcc_optimization_level Enumeration
Use Builtins
arm_use_builtins Boolean
Appendices
Compiler Options
Property
Additional C Compiler Only Options
c_only_additional_options StringList
Description
Enables additional options to be supplied to the
C compiler only. This property will have macro
expansion applied to it.
C Language Standard
gcc_c_language_standard Enumeration
938
Appendices
Folder Options
Property
Description
unity_build_file_name FileName
Preprocessor Options
Property
Ignore Includes
c_ignore_includes Boolean
Preprocessor Definitions
c_preprocessor_definitions StringList
Preprocessor Undefinitions
c_preprocessor_undefinitions StringList
Description
Ignore the include directories properties.
Specifies one or more preprocessor definitions. This
property will have macro expansion applied to it.
Specifies one or more preprocessor undefinitions. This
property will have macro expansion applied to it.
Specifies the system include path. This property will
have macro expansion applied to it.
Does not define any standard preprocessor definitions.
c_undefine_all_preprocessor_definitions Boolean
Section Options
Property
Description
939
Appendices
Post-Compile Command
compile_post_build_command String
Pre-Compile Command
compile_pre_build_command String
Description
A command to run after the compile command has
completed. This property will have macro expansion
applied to it with the additional <b>$(TargetPath)</
b> macro set to the output filepath of the compiler
command.
The working directory where the post-compile
command is run. This property will have macro
expansion applied to it.
A command to run before the compile command. This
property will have macro expansion applied to it.
940
Appendices
Debugging Properties
Debugger Options
Property
Description
Command Arguments
debug_command_arguments String
debug_dependent_projects Boolean
arm_debugIO_Implementation Enumeration
debug_entry_point_symbol String
debug_leave_target_running Boolean
Load File
external_build_file_name ProjFileName
external_load_address String
Load Offset
debug_load_file_offset String
debug_load_file_limit String
debug_register_definition_file_type Enumeration
Start Address
external_start_address String
941
Appendices
Target Connection
debug_target_connection Enumeration
Thread Maximum
debug_threads_max IntegerRange
Threads Script
debug_threads_script ProjFileName
Working Directory
debug_working_directory DirPath
J-Link Options
Property
Connect With Reset
arm_target_connect_with_reset Boolean
Connection
Connection Enumeration
Device Name
arm_target_device_name String
Erase All
target_loader_erase_all Enumeration
Description
Hold the target in hardware reset on connect and
stops the target. This requires the nSRST signal to be
connected and the target debug hardware to work
when in reset.
Either "USB serialNumber" or "IP n.n.n.n" of the J-Link
to use.
The name of the device to connect to. The macro
$(Target) is substituted with the Target Processor
project property value.
Adaptive clocking is enabled.
If set to <b>Yes</b>, all of the FLASH memory on
the target will be erased prior to downloading the
application. If set to <b>No</b>, only the areas of
FLASH containing the program being downloaded will
be erased. If set to <b>Default</b> the behaviour is
target specific.
Address range to exclude from flash cache. This can
be specified by either 'start_address-end_address' or
'address,size'.
The J-Link commands to execute on connect.
942
Appendices
JLinkExecuteCommandDebugStart StringList
JLinkARMDLLFileName FileName
JLinkLogFileName FileName
JLinkProjectFileName FileName
JLinkScriptFileName FileName
Reset Type
resetType IntegerRange
Show Log
showLog Enumeration
Speed
speed IntegerRange
Supply Power
supplyPower Enumeration
traceBufferSize IntegerRange
checkModeAfterRead Enumeration
Loader Options
Property
Description
debug_additional_load_file_address String
943
Appendices
The file type of the additional load file. The options are
debug_additional_load_file_type Enumeration <b>Detect, elf, bin, ihex, hex, tihex, srec</b>.
Additional Load File Type[1]
The file type of the additional load file. The options are
The file type of the additional load file. The options are
The file type of the additional load file. The options are
No Load Sections
target_loader_no_load_sections StringList
Description
Attach Script
target_attach_script JavaScript
Connect Script
target_connect_script JavaScript
Disconnect Script
target_disconnect_script JavaScript
Reset Script
target_reset_script JavaScript
944
Appendices
Description
Specifies the ITM Stimulus ports to enable.
arm_target_itm_stimulus_port_enable IntegerHex
arm_target_itm_stimulus_port_privilege IntegerHex
ITM/DWT PC Sampling
arm_target_dwt_PC_sampling_enable Enumeration
945
Appendices
Specifies the trace port size the target has. The options
are:<ul> <li>1-bit</li> <li>2-bit</li> <li>4-bit</li>
<li>8-bit</li> <li>16-bit</li> <li>24-bit</li> <li>32bit</li></ul>
946
Appendices
Description
Clean Command
external_clean_command String
Description
The command line to build the executable.
The command line to clean the executable.
947
Appendices
Description
File Encoding
file_codec Enumeration
File Type
file_type Enumeration
Flag
file_flag Enumeration
Folder Options
Property
Dynamic Folder Directory
path DirPath
Description
Dynamic folder directory specification.
Dynamic folder exclude specification - ; seperated
wildcards.
Dynamic folder filter specification - ; seperated
wildcards.
Dynamic folder recurse into subdirectories.
The filter specification to exclude from the unity build
- ; seperated wildcards.
Project Options
Property
Description
Flag
project_flag Enumeration
Solution Options
Property
Description
948
Flag
solution_flag Enumeration
Appendices
Description
project_inhibit_indexing Boolean
949
Appendices
Description
build_output_file_name FileName
950
Appendices
Description
link_use_multi_threaded_libraries Boolean
Library Optimization
arm_library_optimization Enumeration
Linker Options
Property
Description
linker_additional_files StringList
linker_additional_options_from_file ProjFileName
from a file.
arm_linker_additional_output_file_gap_fill output
IntegerHex
file.
DebugIO Implementation
arm_link_debugio_type Enumeration
951
Appendices
Emit Relocations
arm_linker_emit_relocations Boolean
Entry Point
gcc_entry_point String
linker_map_file Boolean
Keep Symbols
linker_keep_symbols StringList
Linker
arm_linker_variant Enumeration
link_symbol_definitions StringList
linker_section_placement_file ProjFileName
linker_section_placement_macros StringList
linker_strip_debug_information Boolean
Strip Symbols
gcc_strip_symbols Boolean
arm_linker_no_warn_on_mismatch Boolean
Description
Printf/Scanf Options
Property
Description
952
Appendices
linker_printf_fp_enabled Boolean
linker_printf_fmt_level Enumeration
linker_scanf_character_group_matching_enabled
matching
Boolean
in the scanf functions.
linker_scanf_fp_enabled Boolean
linker_scanf_fmt_level Enumeration
linker_printf_wchar_enabled Boolean
Description
The size of the heap in bytes.
The size of the main stack in bytes.
The size of the process stack in bytes.
The size of the Abort mode stack in bytes.
The size of the FIQ mode stack in bytes.
The size of the IRQ mode stack in bytes.
The size of the Supervisor mode stack in bytes.
The size of the Undefined mode stack in bytes.
Description
953
Post-Link Command
linker_post_build_command String
Pre-Link Command
linker_pre_build_command String
Appendices
954
Appendices
Description
stage_output_filepath String
Set To Read-only
stage_set_readonly Enumeration
Stage Command
stage_command String
955
Appendices
System Macros
System Macro Values
Property
$(Date)
$(Date) String
$(DateDay)
$(DateDay) String
$(DateMonth)
$(DateMonth) String
$(DateYear)
$(DateYear) String
$(DesktopDir)
$(DesktopDir) String
$(DocumentsDir)
$(DocumentsDir) String
$(HomeDir)
$(HomeDir) String
$(HostArch)
$(HostArch) String
$(HostDLL)
$(HostDLL) String
$(HostDLLExt)
$(HostDLLExt) String
$(HostEXE)
$(HostEXE) String
$(HostOS)
$(HostOS) String
$(Micro)
$(Micro) String
$(PackagesDir)
$(PackagesDir) String
$(Platform)
$(Platform) String
$(ProductNameShort)
$(ProductNameShort) String
$(StudioArchiveFileExt)
$(StudioArchiveFileExt) String
Description
Day Month Year e.g. 21 June 2011.
Year e.g. 2011.
Month e.g. June.
Day e.g. 21.
Path to users desktop directory.
Path to users documents directory.
Path to users home directory.
The CPU architecture that SEGGER Embedded Studio is
running on e.g. x86.
The file extension for dynamic link libraries on the CPU
that SEGGER Embedded Studio is running on e.g. .dll.
The file extension for dynamic link libraries used by the
operating system that SEGGER Embedded Studio is
running on e.g. .dll, .so, .dylib.
The file extension for executables on the CPU that
SEGGER Embedded Studio is running on e.g. .exe.
The name of the operating system that SEGGER
Embedded Studio is running on e.g. win.
The SEGGER Embedded Studio target e.g. ARM.
Path to the users packages directory.
The target platform.
The product name.
The filename extension of a studio archive file.
956
$(StudioBuildToolExeName)
$(StudioBuildToolExeName) String
$(StudioBuildToolName)
$(StudioBuildToolName) String
$(StudioDir)
$(StudioDir) String
$(StudioExeName)
$(StudioExeName) String
$(StudioMajorVersion)
$(StudioMajorVersion) String
$(StudioMinorVersion)
$(StudioMinorVersion) String
$(StudioName)
$(StudioName) String
$(StudioNameShort)
$(StudioNameShort) String
$(StudioPackageFileExt)
$(StudioPackageFileExt) String
$(StudioProjectFileExt)
$(StudioProjectFileExt) String
$(StudioScriptToolExeName)
$(StudioScriptToolExeName) String
$(StudioScriptToolName)
$(StudioScriptToolName) String
$(StudioSessionFileExt)
$(StudioSessionFileExt) String
$(StudioUserDir)
$(StudioUserDir) String
$(TargetID)
$(TargetID) String
$(Time)
$(Time) String
$(TimeHour)
$(TimeHour) String
$(TimeMinute)
$(TimeMinute) String
$(TimeSecond)
$(TimeSecond) String
Appendices
957
Appendices
Build Macros
(Build Macro Values)
Property
Description
$(CombiningOutputFilePath)
$(CombiningOutputFilePath) String
$(CombiningRelInputPaths)
$(CombiningRelInputPaths) String
$(Configuration)
$(Configuration) String
$(EXE)
$(EXE) String
$(FolderName)
$(FolderName) String
$(GCCTarget)
$(GCCTarget) String
$(InputDir)
$(InputDir) String
$(InputExt)
$(InputExt) String
$(InputFileName)
$(InputFileName) String
$(InputName)
$(InputName) String
$(InputPath)
$(InputPath) String
$(IntDir)
$(IntDir) String
$(LIB)
$(LIB) String
$(LibExt)
$(LibExt) String
$(OBJ)
$(OBJ) String
$(OutDir)
$(OutDir) String
$(PackageExt)
$(PackageExt) String
958
$(ProjectDir)
$(ProjectDir) String
$(ProjectName)
$(ProjectName) String
$(ProjectNodeName)
$(ProjectNodeName) String
$(RelInputPath)
$(RelInputPath) String
$(RootOutDir)
$(RootOutDir) String
$(RootRelativeOutDir)
$(RootRelativeOutDir) String
$(SolutionDir)
$(SolutionDir) String
$(SolutionExt)
$(SolutionExt) String
$(SolutionFileName)
$(SolutionFileName) String
$(SolutionName)
$(SolutionName) String
$(SolutionPath)
$(SolutionPath) String
$(StageOutputFilePath)
$(StageOutputFilePath) String
$(TargetPath)
$(TargetPath) String
Appendices
959
Appendices
BinaryFile
The following table lists the BinaryFile object's member functions.
BinaryFile.crc32(offset, length) returns the CRC-32 checksum of an address range length bytes long, starting
at offset. This function computes a CRC-32 checksum on a block of data using the standard CRC-32 polynomial
(0x04C11DB7) with an initial value of 0xFFFFFFFF. Note that this implementation doesn't reflect the input or the
output and the result is inverted.
BinaryFile.length() returns the length of the binary file in bytes.
BinaryFile.load(path) loads binary file from path.
BinaryFile.peekBytes(offset, length) returns byte array containing length bytes peeked from offset.
BinaryFile.peekUint32(offset, littleEndian) returns a 32-bit word peeked from offset. The littleEndian argument
specifies the endianness of the access, if true or undefined it will be little endian, otherwise it will be big endian.
BinaryFile.pokeBytes(offset, byteArray) poke byte array byteArray to offset.
BinaryFile.pokeUint32(offset, value, littleEndian) poke a value to 32-bit word located at offset. The littleEndian
argument specifies the endianness of the access, if true or undefined it will be little endian, otherwise it will be
big endian.
BinaryFile.resize(length, fill) resizes the binary image to length bytes. If the operation extends the size, the
binary image will be padded with bytes of value fill.
BinaryFile.save(path) saves binary file to path.
BinaryFile.saveRange(path, offset, length) saves part of the binary file to path. The offset argument specifies
the byte offset to start from. The length argument specifies the maximum number of bytes that should be
saved.
960
Appendices
CWSys
The following table lists the CWSys object's member functions.
CWSys.appendStringToFile(path, string) appends string to the end of the file path.
CWSys.copyFile(srcPath, destPath) copies file srcPath to destPath.
CWSys.crc32(array) returns the CRC-32 checksum of the byte array array. This function computes a CRC-32
checksum on a block of data using the standard CRC-32 polynomial (0x04C11DB7) with an initial value of
0xFFFFFFFF. Note that this implementation doesn't reflect the input or the output and the result is inverted.
CWSys.fileExists(path) returns true if file path exists.
CWSys.exit(status) terminates CrossScript with exit code status (CrossScript Only).
CWSys.fileSize(path) return the number of bytes in file path.
CWSys.getRunStderr() returns the stderr output from the last CWSys.run() call.
CWSys.getRunStdout() returns the stdout output from the last CWSys.run() call.
CWSys.makeDirectory(path) create the directory path.
CWSys.packU32(array, offset, number, le) packs number into the array at offset.
CWSys.popup(text) prompt the user with text and return true for yes and false for no.
CWSys.readByteArrayFromFile(path) returns the byte array contained in the file path.
CWSys.readStringFromFile(path) returns the string contained in the file path.
CWSys.removeDirectory(path) remove the directory path.
CWSys.removeFile(path) deletes file path.
CWSys.renameFile(oldPath, newPath) renames file oldPath to be newPath.
CWSys.run(cmd, wait) runs command line cmd optionally waits for it to complete if wait is true.
CWSys.unpackU32(array, offset, le) returns the number unpacked from the array at offset.
CWSys.writeByteArrayToFile(path, array) creates a file path containing the byte array array.
CWSys.writeStringToFile(path, string) creates a file path containing string.
961
Appendices
Debug
The following table lists the Debug object's member functions.
Debug.breakexpr(expression, count, hardware) set a breakpoint on expression, with optional ignore count
and use hardware parameters. Return the, none zero, allocated breakpoint number.
Debug.breakline(filename, linenumber, temporary, count, hardware) set a breakpoint on filename and
linenumber, with optional temporary, ignore count and use hardware parameters. Return the, none zero,
allocated breakpoint number.
Debug.breaknow() break execution now.
Debug.deletebreak(number) delete the specified breakpoint or all breakpoints if zero is supplied.
Debug.disassembly(source, labels, before, after) set debugger mode to disassembly mode. Optionally specify
source and labels to be displayed and the number of bytes to disassemble before and after the located program
counter.
Debug.echo(s) display string.
Debug.enableexception(exception, enable) enable break on exception.
Debug.evaluate(expression) evaluates debug expression and returns it as a JavaScript value.
Debug.getfilename() return located filename.
Debug.getlineumber() return located linenumber.
Debug.go() continue execution.
Debug.locate(frame) locate the debugger to the optional frame context.
Debug.locatepc(pc) locate the debugger to the specified pc.
Debug.locateregisters(registers) locate the debugger to the specified register context.
Debug.print(expression, fmt) evaluate and display debugexpression using optional fmt. Supported formats are
b binary, c character, d decimal, e scientific float, f decimal float, g scientific or decimal float, i signed decimal, o
octal, p pointer value, s null terminated string, u unsigned decimal, x hexadecimal.
Debug.printglobals() display global variables.
Debug.printlocals() display local variables.
Debug.quit() stop debugging.
Debug.setprintarray(elements) set the maximum number of array elements for printing variables.
Debug.setprintradix(radix) set the default radix for printing variables.
Debug.setprintstring(c) set the default to print character pointers as strings.
Debug.showbreak(number) show information on the specified breakpoint or all breakpoints if zero is
supplied.
Debug.showexceptions() show the exceptions.
Debug.source(before, after) set debugger mode to source mode. Optionally specify the number of source
lines to display before and after the location.
Debug.stepinto() step an instruction or a statement.
962
Appendices
963
Appendices
ElfFile
The following table lists the ElfFile object's member functions.
ElfFile.crc32(address, length, virtualNotPhysical, padding) returns the CRC-32 checksum of an address range
length bytes long, located at address. If virtualNotPhysical is true or undefined, address is a virtual address
otherwise it is a physical address. If padding is defined, it specifies the byte value used to fill gaps in the
program. This function computes a CRC-32 checksum on a block of data using the standard CRC-32 polynomial
(0x04C11DB7) with an initial value of 0xFFFFFFFF. Note that this implementation doesn't reflect the input or the
output and the result is inverted.
ElfFile.findProgram(address) returns an object with start, the data and the size to allocate of the Elf program
that contains address.
ElfFile.getEntryPoint() returns the entry point in the ELF file.
ElfFile.getSection(name) returns an object with start and the data of the Elf section corresponding to the
name.
ElfFile.isLittleEndian() returns true if the Elf file has numbers encoded as little endian.
ElfFile.load(path) loads Elf file from path.
ElfFile.peekBytes(address, length, virtualNotPhysical, padding) returns byte array containing length bytes
peeked from address. If virtualNotPhysical is true or undefined, address is a virtual address otherwise it is a
physical address. If padding is defined, it specifies the byte value used to fill gaps in the program.
ElfFile.peekUint32(address, virtualNotPhysical) returns a 32-bit word peeked from address. If
virtualNotPhysical is true or undefined, address is a virtual address otherwise it is a physical address.
ElfFile.pokeBytes(address, byteArray, virtualNotPhysical) poke byte array byteArray to address. If
virtualNotPhysical is true or undefined, address is a virtual address otherwise it is a physical address.
ElfFile.pokeUint32(address, value, virtualNotPhysical) poke a value to 32-bit word located at address. If
virtualNotPhysical is true or undefined, address is a virtual address otherwise it is a physical address.
ElfFile.save(path) saves Elf file to path.
ElfFile.symbolValue(symbol) returns the value of symbol in Elf file.
964
Appendices
TargetInterface
The following table lists the TargetInterface object's member functions.
TargetInterface.beginDebugAccess() puts the target into debug state if it is not already in order to
carry out a number of debug operations. The idea behind beginDebugAccess and endDebugAccess is
to minimize the number of times the target enters and exits debug state when carrying out a number of
debug operations. Target interface functions that require the target to be in debug state (such as peek and
poke) also use beginDebugAccess and endDebugAccess to get the target into the correct state. A nesting
count is maintained, incremented by beginDebugAccess and decremented by endDebugAccess. The initial
processor state is recorded on the first nested call to beginDebugAccess and this state is restored when the
final endDebugAccess is called causing the count to return to it initial state.
TargetInterface.commReadWord() returns a word from the ARM7/ARM9 debug comms channel.
TargetInterface.commWriteWord(word) writes a word to the ARM7/ARM9 debug comms channel.
TargetInterface.crc32(address, length) reads a block of bytes from target memory starting at address for
length bytes, generates a crc32 on the block of bytes and returns it.
TargetInterface.cycleTCK(n) provide n TCK clock cycles.
TargetInterface.delay(ms) waits for ms milliseconds
TargetInterface.downloadDebugHandler() downloads the debug handler as specified by the Debug Handler
File Path/Load Address project properties and uses the debug handler for the target connection.
TargetInterface.endDebugAccess(alwaysRun) restores the target run state recorded at the first nested call to
beginDebugAccess. See beginDebugAccess for more information. If alwaysRun is non-zero the processor will
exit debug state on the last nested call to endDebugAccess.
TargetInterface.eraseBytes(address,length) erases a length block of target memory starting at address.
TargetInterface.error(message) terminates execution of the script and outputs a target interface error
message to the target log.
TargetInterface.executeFunction(address, parameter, timeout) calls a function at address with the parameter
and returns the function result. The timeout is in milliseconds.
TargetInterface.executeMCR(opcode) interprets/executes the opcode assuming it to be an MRC instruction
and returns the value of the specified coprocessor register.
TargetInterface.executeMCR(opcode, value) interprets/executes the opcode assuming it to be an MCR
instruction that writes value to the specified coprocessor register.
TargetInterface.expandMacro(string) returns the string with macros expanded.
TargetInterface.fillScanChain(bool, lsb, msb) sets bits from lsb (least significant bit) to msb (most significant
bit) in internal buffer to bool value.
TargetInterface.getDebugRegister(address) returns the value of the ADIv5 debug register denoted by
address. Address has the nibble sized access point number starting at bit 24 and the register number in the
bottom byte.
TargetInterface.getICEBreakerRegister(r) returns the value of the ARM7/ARM9/ARM11/CortexA/CortexR
debug register r.
TargetInterface.getProjectProperty(savename) returns the value of the savename project property.
965
Appendices
TargetInterface.getRegister(registername) returns the value of the register, register is a string specifying the
register to get and must be one of r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, sp, lr, pc, cpsr, r8_fiq,
r9_fiq, r10_fiq, r11_fiq, r12_fiq, r13_fiq, r14_fiq, spsr_fiq, r13_svc, r14_svc, spsr_svc, r13_abt, r14_abt, spsr_abt,
r13_irq, r14_irq, spsr_irq, r13_und, r14_und, spsr_und.
TargetInterface.getTDO() return the TDO signal.
TargetInterface.getTargetProperty(savename) returns the value of the savename target property.
TargetInterface.go() allows the target to run.
TargetInterface.idcode() returns the JTAG idcode of the target.
TargetInterface.implementation() returns a string defining the target interface implementation.
TargetInterface.isStopped() returns true if the target is stopped.
TargetInterface.message(message) outputs a target interface message to the target log.
TargetInterface.packScanChain(data, lsb, msb) packs data from lsb (least significant bit) to msb (most
significant bit) into internal buffer.
TargetInterface.peekBinary(address, length, filename) reads a block of bytes from target memory starting at
address for length bytes and writes them to filename.
TargetInterface.peekByte(address) reads a byte of target memory from address and returns it.
TargetInterface.peekBytes(address, length) reads a block of bytes from target memory starting at address for
length bytes and returns the result as an array containing the bytes read.
TargetInterface.peekMultUint16(address, length) reads length unsigned 16-bit integers from target memory
starting at address and returns them as an array.
TargetInterface.peekMultUint32(address, length) reads length unsigned 32-bit integers from target memory
starting at address and returns them as an array.
TargetInterface.peekUint16(address) reads a 16-bit unsigned integer from target memory from address and
returns it.
TargetInterface.peekUint32(address) reads a 32-bit unsigned integer from target memory from address and
returns it.
TargetInterface.peekWord(address) reads a word as an unsigned integer from target memory from address
and returns it.
TargetInterface.pokeBinary(address, filename) reads a block of bytes from filename and writes them to target
memory starting at address.
TargetInterface.pokeByte(address, data) writes the byte data to address in target memory.
TargetInterface.pokeBytes(address, data) writes the array data containing 8-bit data to target memory at
address.
TargetInterface.pokeMultUint16(address, data) writes the array data containing 16-bit data to target memory
at address.
TargetInterface.pokeMultUint32(address, data) writes the array data containing 32-bit data to target memory
at address.
TargetInterface.pokeUint16(address, data) writes data as a 16-bit value to address in target memory.
TargetInterface.pokeUint32(address, data) writes data as a 32-bit value to address in target memory.
966
Appendices
967
Appendices
968
Appendices
TargetInterface.setRegister(registername, value) sets the register to the value, register is a string specifying
the register to get and must be one of r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, sp, lr, pc, cpsr,
r8_fiq, r9_fiq, r10_fiq, r11_fiq, r12_fiq, r13_fiq, r14_fiq, spsr_fiq, r13_svc, r14_svc, spsr_svc, r13_abt, r14_abt,
spsr_abt, r13_irq, r14_irq, spsr_irq, r13_und, r14_und, spsr_und.
TargetInterface.setTDI(v) clear/set TDI signal.
TargetInterface.setTMS(v) clear/set TMS signal.
TargetInterface.setTargetProperty(savename) set the value of the savename target property.
TargetInterface.stop() stops the target.
TargetInterface.stopAndReset(delay) sets a breakpoint on any instruction execution, resets the target by
cycling nSRST and waits for the breakpoint to be hit. delay is the number of milliseconds to hold the device in
reset.
TargetInterface.trst() resets the target interface (not the target).
TargetInterface.type() returns a string defining the target interface type.
TargetInterface.unpackScanChain(lsb, msb) unpacks data from lsb (least significant bit) to msb (most
significant bit) from internal buffer and returns the result.
TargetInterface.waitForDebugState(timeout) waits for the target to stop or the timeout in milliseconds.
TargetInterface.writeBinary(array, filename) write the bytes in array to filename.
969
Appendices
WScript
The following table lists the WScript object's member functions.
WScript.Echo(s) echos string s to the output terminal.
970