*
*Home|Chinese|Japanese*About ARM|Forums|Events|News|Employment|Contact Us|Investors*
dotted rule
*ARM - the architecture for the digital worldARM - the architecture for the digital world
search
*
*
***
*MARKETS:PRODUCTS & SOLUTIONS:CONNECTED COMMUNITY:TECHNICAL SUPPORT:DOCUMENTATION*
*
technical support
*
*
****
*.Technical Support
*
*
*>>Home Page*
*
*.Obtaining Support*
*
*.FAQs*
*
**Development Tool FAQs*
**IP FAQs*
**Embedded Software FAQs*
**Artisan Physical IP FAQs (Login Required)*
*
*.Downloads*
*
*.Documentation*
*
*.Training*
*
*.Where To Buy*
*
*.Keil MCU Tools*
*
*.What's New*
*
*.ARM Newsgroups*
*
*.Active Assist On-site Services*
*
*
*
technical support FAQsask ARM*
*

Technical Support Search
*     (Advanced Search)
  FAQs   Documentation   Downloads   Forums

*

 
downarrowHow do I retarget C++ streamed I/O?
Applies to: ARM Developer Suite (ADS), Compilers, General Build Issues, Libraries, RealView Developer Kit (RVDK) for OKI , RealView Developer Kit (RVDK) for ST, RealView Developer Kit for XScale (RVXDK), RealView Developer Suite (RVDS) 2.0, RealView Developer Suite (RVDS) 2.1, RealView Developer Suite (RVDS) 2.2, RealView Development Suite (RVDS) 3.0, RealView Development Suite (RVDS) 3.1

The C++ libraries depend on the C library for target-specific support. There are no target dependencies in the C++ libraries.

To retarget your C++ streamed I/O, we recommend that you retarget the “_sys_xxxx” driver level functions. These are the functions used by the C and C++ library and are responsible for target specific I/O. The default implementation uses Semihosting to handle I/O on the host machine.

The RVDS Compiler and Libraries Guide discusses which functions have to be re-implemented. A summary is shown below:

_sys_open()
_sys_close()
_sys_read()
_sys_write()
_sys_ensure()
_sys_flen()
_sys_seek()
_sys_istty()
_sys_tmpnam()
_sys_exit()
_ttywrch() 
 
For an example file (retarget.c), used for redirecting C++ streamed I/O to an UART (connected to e.g. a Terminal Emulator), click here.

To retarget standard input/output functionality, low level library functions such as fgetc() and fputc()can be re-implemented instead.

In ADS 1.2 and RVDS 3.x, only functions such as fgetc() and fputc() need to be reimplemented. With RVDS 2.x an additional library function (used by cin) '__fread_bytes_avail()' must also be reimplemented.

The default version of '__fread_bytes_avail()'  fills a buffer by calling fgetc() until either the buffer is filled or EOF is encountered.  Since the retargeted version of fgetc() in the example code simply returns characters from a UART (and never returns EOF), __fread_bytes_avail() must be re-implemented to read a single character by calling fgetc():
 
#ifdef __cplusplus
extern "C"
#endif
size_t __fread_bytes_avail(void *buf, size_t nbytes, FILE *stream)
/* Read a single character into buf[] using fgetc() */
{
  *(char *)buf = (char)fgetc(stream);
  return 1;
}

This function should be added to 'retarget.c' in the Application Note 107  code /RVCT 'emb_sw_dev' example.

For ADS users, general retargeting of I/O functions is described in Application Note 107 , "Embedded Software Development".

Download

 TEXT Icon retarget.c 





back to top

*
**
*4 dots*Other ARM Websites | Help with Accessibility
*
shadow *LEGAL STATEMENTshadow