Datasheet
The C and C++ Libraries
ARM DUI 0067D Copyright © 1999-2001 ARM Limited. All rights reserved. 4-43
Note
Because the compiler optimizes the data segment, it reorders and removes parts of
locale definitions, and breaks the data structures. The code examples provided are for
informational purposes only. In practice, the definitions require additional pragmas to
disable optimizations.
4.6.14 __LC_COLLATE_DEF
This macro is used to create collate blocks used when sorting ASCII characters. The
definition from
rt_locale.h
, the definition of a macro for creating an empty table, and
sample code are shown in Example 4-10 and Example 4-11.
For all the macros, the first two arguments are a symbol prefix and a locale name. The
resulting locale block is addressed by the expression
&symprefix_start
, and the index
entry by the expression
&symprefix_index
.
Example 4-10 Macro for use with array
#define __LC_COLLATE_DEF(sym,ln) \
static const int sym##_index = ~3&(3+(268+(~3&(3+sizeof(ln))))); \
static const char sym##_lname[~3 & (3 + sizeof(ln))] = ln; \
static const int sym##_pname = -4-(~3 & (3 + sizeof(ln))); \
static const int sym##_start = 4; \
static const char sym##_table[] =
Example 4-11 Macro that generates default table
#define __LC_COLLATE_TRIVIAL_DEF(sym,ln) \
static const int sym##_index = ~3&(3+(12+(~3&(3+sizeof(ln))))); \
static const char sym##_lname[~3 & (3 + sizeof(ln))] = ln; \
static const int sym##_pname = -4-(~3 & (3 + sizeof(ln))); \
static const int sym##_start = 0;
Usage
See _get_lc_collate() on page 4-32. See also __LC_CTYPE_DEF on page 4-42 for
details of the side-effects of compiler optimizations.