LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 862|回复: 4

两个宏定义

[复制链接]
发表于 2006-1-6 12:31:44 | 显示全部楼层 |阅读模式
  1. #define _(String) String
  2. #define N_(String) String
复制代码


常在源代码里看到这两个宏,特别是第一个宏,作用是?

像用在printf里。
  1. printf(_("hello world.\n"))
复制代码
发表于 2006-1-6 12:44:19 | 显示全部楼层
似乎就是替换成了
printf("hello world.\n");
可能是为了将来扩展成wchar_t吧?变成L##String?个人猜想……
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-1-6 16:35:27 | 显示全部楼层
在coreutils里找到解释
  1. /* Disabled NLS.
  2.    The casts to 'const char *' serve the purpose of producing warnings
  3.    for invalid uses of the value returned from these functions.
  4.    On pre-ANSI systems without 'const', the config.h file is supposed to
  5.    contain "#define const".  */
  6. # define gettext(Msgid) ((const char *) (Msgid))
  7. #define _(msgid) gettext (msgid)
  8. #define N_(msgid) msgid
复制代码
回复 支持 反对

使用道具 举报

发表于 2006-1-10 09:07:22 | 显示全部楼层
这样的定义经常用户gettext的替换



#define _(x) gettext(x)
回复 支持 反对

使用道具 举报

发表于 2006-1-10 09:54:26 | 显示全部楼层
这是设置 "本地语言支持" 的开关, 楼主可看下i18n 和 L10n的资料.例如汉化,
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表