ARM Technical Support Knowledge Articles

Problems with sprintf, when printing doubles or long longs

Applies to: DS-5, RealView Development Suite (RVDS)


If you are encountering problems when printing double or long long using sprintf  it is often caused by one of three issues. We recommend that you check:

  1. Your code (including an OS if you are using one) maintains 8-byte stack alignment at all its external public interfaces as required by the ABI and checked by the linker. If not, please contact your OS vendor.

  2. The ARM-supplied libraries are being initialised correctly.

    Does your software have a main()? If so, __main() will call __rt_entry -> __rt_lib_init. If you do not have a main(), you need to ensure that the library init code is called correctly.

    There are recommendations in the RVCT libraries guide. It explains how you can initialize specific parts of the C-library as needed (e.g. the locale), rather than all of it via __rt_entry. How to set the locale is detailed in the "C library character and string function problems" article.

  3. The __user_libspace static data area (a block of 96 bytes in the ZI segment which holds the static data for the C libraries,  such as the locale settings) is being set up correctly, and is not being accidentally overwritten at runtime. You can check this by opening a memory window over these areas using a debugger, and check that it is not corrupted.  For further information about __user_libspace see the ARM C and C++ Libraries documentation

Article last edited on: 2011-09-30 17:24:21

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential