|
|||
Home > C 和 C++ 库 > 使用 C 宏调整区域设置和 CTYPE > __LC_COLLATE_DEF |
此宏用于创建在对 ASCII 字符进行排序时使用的归类块。 Example 2.17 和Example 2.18 显示了 rt_locale.h
中的定义、用于创建空表的宏的定义以及示例代码。
这些示例并不完整,因此,请参阅 rt_locale.h
包含文件以了解详细信息。
对于所有这些宏,前两个参数是符号前缀和区域设置名称。 生成的区域设置块的地址由表达式 &symprefix_start
确定,索引项由表达式 &symprefix_index
确定。
Example 2.17. 用于数组的宏
#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 2.18. 生成缺省表的宏
#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;
请参阅_get_lc_collate()。 有关编译器优化副作用的详细信息,另请参阅__LC_CTYPE_DEF。