ARM Technical Support Knowledge Articles

C library character and string function problems

Applies to: ARM Developer Suite (ADS), RealView Development Suite (RVDS)


If the locale has not been correctly initialized or it is being accidentally overwritten at runtime, you might encounter problems caused by one of the following functions:

A typical problem you might encounter could be the function call isdigit('1') returning 0 rather than 1.

Most cases of such behavior are caused by bypassing the C library standard initialization code by providing your own __main() function. The best solution is to ensure that the C library's initialization code in __rt_lib_init() is called correctly. This will setup locale and any other C library functions which need to be initialized automatically.

Alternatively, you can work around the problem by calling setlocale() before calling any function that uses locale functions. For example:

#include <locale.h>


This workaround is possible because the setlocale() function is a standalone C library function. For more information, please see 'Table 5. Standalone C library functions' in the ARM Compiler toolchain, Version 4.1 - Using ARM C and C++ Libraries and Floating-Point Support document.

Article last edited on: 2016-05-31 21:46:30

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