在尝试编译解释器时,我不断收到使用 gets() 警告,并且终端中没有任何输出。我也将 gets() 更改为 fgets() 但它仍然不输出任何内容并给我一个错误:
$ ./littleLisp
warning: this program uses gets(), which is unsafe.
5.000000
littleLisp.c:16:18: error: too few arguments to function call, expected 3, have 1
while (fgets(str) && strcmp(str, "")) {
~~~~~ ^
/usr/include/stdio.h:238:1: note: 'fgets' declared here
char *fgets(char * __restrict, int, FILE *);
^
1 error generated.
make: *** [littleLisp] Error 1
$ make littleLisp
cc littleLisp.c -o littleLisp
littleLisp.c:16:18: error: too few arguments to function call, expected 3, have 1
while (fgets(str) && strcmp(str, "")) {
~~~~~ ^
/usr/include/stdio.h:238:1: note: 'fgets' declared here
char *fgets(char * __restrict, int, FILE *);
^
1 error generated.
make: *** [littleLisp] Error 1
知道发生了什么吗?
要点如下:
最佳答案
根据 man page fgets()
的语法为
char *fgets(char *s, int size, FILE *stream);
因此,对 fgets()
的调用需要具有三个参数。
在您的代码中,while (fgets(str).....
,它只有一个。
关于c - 在 C 中编译 Lisp 解释器时收到警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28179315/