ARM Technical Support Knowledge Articles

C library character and string function problems

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

Answer

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

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

Most cases of such behaviour are caused by bypassing the C library standard initialization code, for example, by providing your own __main() function. The best solution to this 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 should be able to work around the problem by calling the setlocale() before calling any function that uses locale functions, for example:

#include <locale.h>

setlocale(LC_ALL,"C");

This work around is possible because the setlocale() function is a stand alone C library function.  For more information, please see 'Table 5. Standalone C library functions' from the ARM Compiler toolchain - Using ARM C and C++ Libraries and Floating-Point Support document.

Article last edited on: 2011-04-07 09:51:59

Rate this article

[Bad]
|
|
[Good]
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