|Non-Confidential||PDF version||ARM 100073_0608_00_en|
|Home > The ARM C and C++ Libraries > Support for building an application with the C library > Using the libraries in a nonsemihosting environment|
Some C library functions use semihosting. If you use the libraries in a nonsemihosting environment, you must ensure that semihosting function calls are dealt with appropriately.
If you do not want to use semihosting, either:
Re-implement the lower-level functions, for example,
fputc(). You are not required to re-implement all
semihosting functions. You must, however, re-implement the functions you are using in
You must re-implement functions that the C library uses to isolate
itself from target dependencies. For example, if you use
printf() you must re-implement
you do not use the higher-level input/output functions like
printf(), you do not have to re-implement the lower-level functions like
To guarantee that no functions using semihosting are included in your application, use either:
IMPORT __use_no_semihostingfrom armasm assembly language.
__asm(".global __use_no_semihosting\n\t")for C or C++ code.
IMPORT __use_no_semihostingis only required to be added to a single assembly source file. Similarly,
__asm(".global __use_no_semihosting\n\t")is only required to be added to a single C source file. It is unnecessary to add these inserts to every single source file.
If you include a library function that uses semihosting and also reference __use_no_semihosting, the library detects the conflicting symbols and the linker reports an error. For example, to determine which objects are using semihosting when using an ARMv8-M processor:
armlink --cpu=8-M --verbose --list err.txt
Search err.txt for occurrences of
... Loading member sys_exit.o from c_2.l. reference : __I$use$semihosting definition: _sys_exit ...
This shows that the semihosting-using function
_sys_exit is linked-in from the C library. To
prevent this, you must provide your own implementation of this
There are no target-dependent functions in the C++ library, although some C++ functions use underlying C library functions that are target-dependent.