【发布时间】:2011-07-25 00:14:30
【问题描述】:
这是我代码的小sn-p。
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
...
FILE * pipe;
...
pipe = popen ("ls /tmp -1", "r");
...
pclose(pipe);
blarg.c:106: warning: implicit declaration of function ‘popen’
blarg.c:106: warning: assignment makes pointer from integer without a cast
blarg.c:112: warning: implicit declaration of function ‘pclose’
blarg.c:118: warning: assignment makes pointer from integer without a cast
我真的不确定。我查找了 popen,它只需要提供的 stdio.h。缺少什么,或者是我的其余代码中的问题(我真的不想显示更多代码,因为它是一个赋值)。
【问题讨论】:
-
也许您正在使用 GCC 的选项进行编译,例如
-ansi或-std=c99;这些会阻止 POSIX 扩展可见。要使它们可见,您必须在包含任何系统标头之前通过(例如)指定#define _XOPEN_SOURCE 500(或 600 或 700)来请求它们。 -
不错的相关帖子:stackoverflow.com/questions/5378778/…>
标签: c declaration pipe implicit stdio