微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

_(“text”),即下划线括号char,做什么?

在C代码中,我遇到了这个问题
_("test")

它有什么作用? (我试着自己查一下,但是你可以想象,搜索引擎不支持搜索…)

解决方法

它正在调用名为_的函数.例如:
#include <stdio.h>

void _(int a) {
    printf("%d",a);
}
int main(void) {
         _(3);
        return 0;
}

_是gettext library中的现有函数,用于国际化.如this answer所述:

This function basically replaces the given string on runtime with a translation in the system’s language,if available (i.e. if they shipped a .mo file for this language with the program).

原文地址:https://www.jb51.cc/html/242461.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐