gpt4 book ai didi

c - xlC 警告 'Initialization between types "struct {...} *"and "int“不允许。”

转载 作者:行者123 更新时间:2023-12-01 06:32:42 25 4
gpt4 key购买 nike

下面的程序om.c通过xlC编译成功,除了关于1506-196的警告!!!

谁能解释一下这样的警告信息!?

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char ch_sh[]="This is a program!!";
char k1[1200];
char *ls_sh=NULL;
size_t len=0;
FILE *om = open_memstream(&ls_sh, &len);
fprintf(om, " %32s", ch_sh);
if ( argv[1] != NULL )
{
fprintf(om, "%26s", argv[1]);
fclose(om);
sprintf(k1, "echo %s", ls_sh);
system(k1);
printf("\ndone message in program\n");
}
else
{
printf("Error: Empty input\n");
return 1;
}
free(ls_sh);
}

编译器日志:

 1. root@psph:/tmp# 
root@psph:/tmp#
root@psph:/tmp#
root@psph:/tmp# xlC -o om om.c
"om.c", line 11.14: 1506-196 (W) Initialization between types "struct {...}*" and "int" is not allowed.
root@psph:/tmp#
root@psph:/tmp# xlC -qsrcmsg -o om om.c
11 | FILE *om = open_memstream(&ls_sh, &len);
.............a..............................
a - 1506-196 (W) Initialization between types "struct {...}*" and "int" is not allowed.

root@psph:/tmp# ./om data1
This is a program!! data1
done message in program
root@psph:/tmp#
root@psph:/tmp# xlC -qversion
IBM XL C/C++ for AIX, V11.1 (5724-X13)
Version: 11.01.0000.0000
Driver Version: 11.01(C/C++) Level: 100304
C Front End Version: 11.00(C/C++) Level: 100301
C++ Front End Version: 11.01(C/C++) Level: 100304
High-Level Optimizer Version: 11.01(C/C++) and 13.01(Fortran) Level: 100301
Low-Level Optimizer Version: 11.01(C/C++) and 13.01(Fortran) Level: 100304
root@psph:/tmp#
root@psph:/tmp#
root@psph:/tmp#

就这些!

最佳答案

警告说您正在影响指向指针的 int 值,这通常是由间接级别错误引起的。并且 open_memstream 不是标准 C 而是 POSIX。

这里,很可能对于xlC,open_memstream没有在stdio.h中声明。然后编译器假定它应该是一个返回 int 的函数,因此发出警告。您应该询问 man (man open_memstream) 以了解它在哪个包含文件中声明并将其包含在您的源代码中。

关于c - xlC 警告 'Initialization between types "struct {...} *"and "int“不允许。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43896750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com