C 使用gnuplot的编译警告
我想在Linux的代码中使用gnuplot,所以我写了这行:C 使用gnuplot的编译警告,c,compilation,gnuplot,compiler-warnings,C,Compilation,Gnuplot,Compiler Warnings,我想在Linux的代码中使用gnuplot,所以我写了这行: FILE *gnuplotPipe = popen ("gnuplot -persistent", "w"); 编译器给了我这个警告: warning: initialization makes pointer from integer without a cast 有人能解释一下这个警告是什么吗?我该怎么做才能正确地做呢?你忘了把 #include <stdio.h> #包括 在文件的顶部 头文件包含函数的定义,
FILE *gnuplotPipe = popen ("gnuplot -persistent", "w");
编译器给了我这个警告:
warning: initialization makes pointer from integer without a cast
有人能解释一下这个警告是什么吗?我该怎么做才能正确地做呢?你忘了把
#include <stdio.h>
#包括
在文件的顶部
头文件包含函数的定义,包括popen()
的定义。它告诉编译器popen()
返回一个文件*
如果不包括头文件,编译器将采用默认返回值,即
int
。因此,可以解释警告:编译器认为popen()
返回一个int
,然后想把它分配给一个文件*
你确定警告来自这一行吗?你是否在顶部包含了#include
。@SouravGhosh很可能是这样。@paramagneticscroissant是的,对,虽然没有转发声明[头文件],但我包含了stdio.hI和stdio.h