标题:
[其他]
问个c问题
[打印本页]
作者:
窗户
时间:
2008-7-22 12:23
标题:
问个c问题
见到别人程序如下所写,
fputs (_("\
blablabla.\n"), stream);
自己照着写了一下,编译报错,
warning: passing argument 1 of ‘fputs’ makes pointer from integer without a cast
。。。
util.c:(.text+0x1758): undefined reference to `_'
collect2: ld returned 1 exit status
make: *** [automata] Error 1
说fputs第一个参数的 _ 没有定义
那位高人指点一下,到底如何使用fputs(_("blabla..."), stream)
作者:
驴子
时间:
2008-7-22 12:34
fputs (_("\blablabla.\n"), stream);
别人的程序你确定编译不报错么?
fputs的语法是
fputs(setence,file)
把第一个参数写入第二个参数里
作者:
窗户
时间:
2008-7-22 12:39
fputs (“\
blablabla.\n", stream);
这么写肯定没错,显示出来是blabla前面很多空格。
我发现fputs (_("\
blablabla.\n"), stream);好像能控制格式
如果显示出来,前面没有那么多空格。
可以肯定人家的没错,我看的是gnu的源码。
作者:
窗户
时间:
2008-7-22 12:42
刚才有一点说错了,fputs(_("asdfasdf\n"), stream);
不能控制格式。
我就是不明白他为什么能这么写
作者:
橙色坦克
时间:
2008-7-22 12:45
这段源码在哪里可以看到?
作者:
窗户
时间:
2008-7-22 12:49
gnu bison getargs.c
[
本帖最后由 窗户 于 2008-7-22 13:52 编辑
]
附件:
getargs.c
(2008-7-22 12:52, 6.51 KB) / 下载次数 133
http://csuchen.de/bbs/attachment.php?aid=310990&k=1202e4b8a6096b48f7262531a28b6971&t=1739723724&sid=nbyMoH
附件:
getargs.h
(2008-7-22 12:52, 1.49 KB) / 下载次数 137
http://csuchen.de/bbs/attachment.php?aid=310991&k=ffbcf91a676da9d3e28bdc1f7e8a6fce&t=1739723724&sid=nbyMoH
作者:
橙色坦克
时间:
2008-7-22 13:29
有些头文件你没#include吧?我把下面这个文件放到bison/src里:
fputs.c
-----------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include "config.h"
#include "system.h"
#include "argmatch.h"
#include <error.h>
#include "complain.h"
#include "files.h"
#include "getargs.h"
#include "uniqstr.h"
int main(int argc, char** argv)
{
fprintf(stderr,_("%s\n"),"test");
return 0;
}
-----
把它要的文件统统拷到src里来,然后
gcc fputs
没啥问题。
作者:
橙色坦克
时间:
2008-7-22 13:40
看到了,不用搞的这么复杂,下划线不过是gettext的macro罢了,详情请见src/system.h第123行。
作者:
窗户
时间:
2008-7-22 13:48
ok,明白了。多谢
欢迎光临 人在德国 社区 (http://csuchen.de/bbs/)
Powered by Discuz! 7.2