Chr*_*len 14 c declaration pipe stdio implicit
这是我的代码的一小部分.
#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);
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我真的不确定.我查了一下popen,它需要的是stdio.h.缺少什么,或者是我的其余代码中的问题(我真的不想显示更多的代码,因为它是一个赋值).
Con*_*yer 13
正如手册页所说:
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
popen(), pclose(): _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE || _BSD_SOURCE
|| _SVID_SOURCE
Run Code Online (Sandbox Code Playgroud)
所以,你应该#define _BSD_SOURCE还是之前别人的一个#include荷兰国际集团stdio.h.
| 归档时间: |
|
| 查看次数: |
8615 次 |
| 最近记录: |