| |||
| Home > The C and C++ Libraries > Tailoring locale and CTYPE > __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 5.10 and Example 5.11. These examples
are incomplete, so refer to rt_locale.h for
details.
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 5.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 5.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;
See _get_lc_collate(). See also __LC_CTYPE_DEF for details of the side-effects of compiler optimizations.