当前位置: 技术问答>linux和unix
哪个头文件定义了 '_IO_*' ?
来源: 互联网 发布时间:2016-06-09
本文导语: 在Solaris 10下编译下面的文件: #include #include #include #include #include #include #include #include #include #include #define _IO_UNBUFFERED __SNBF #define _IO_LINE_BUF __SLBF #define _IO_file_flags _flags #define BUFFERSZ(fp) (fp)->_bf._size vo...
在Solaris 10下编译下面的文件:
在编译的过程中产生下面的错误:
In function 'pr_stdio':
error:structure has no member named '_IO_file_flags'
error:'_IO_UNBUFFERED' undeclared
error:'_IO_LINE_BUF' undeclared
error:structure has no member named '_IO_buf_end'
error:structure has no member named '_IO_buf_base'
为什么会产生上面的错误呢?是不是哪个头文件没有引进来?
谢谢!
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define _IO_UNBUFFERED __SNBF
#define _IO_LINE_BUF __SLBF
#define _IO_file_flags _flags
#define BUFFERSZ(fp) (fp)->_bf._size
void pr_stdio(const char *, FILE *);
int
main(void)
{
FILE *fp;
fputs("enter any charactern", stdout);
if (getchar() == EOF)
err_sys("getchar error");
fputs("one line to standard errorn", stderr);
pr_stdio("stdin", stdin);
pr_stdio("stdout", stdout);
pr_stdio("stderr", stderr);
if ((fp = fopen("/etc/motd", "r")) == NULL)
err_sys("fopen error");
if (getc(fp) == EOF)
err_sys("getc error");
pr_stdio("/etc/motd", fp);
exit(0);
}
void pr_stdio(const char *name, FILE *fp)
{
printf("stream = %s, ", name);
/*
* The following is nonportable.
*/
if (fp->_IO_file_flags & _IO_UNBUFFERED)
printf("unbuffered");
else if (fp->_IO_file_flags & _IO_LINE_BUF)
printf("line buffered");
else /* if neither of above */
printf("fully buffered");
printf(", buffer size = %dn", BUFFERSZ(fp));
}
在编译的过程中产生下面的错误:
In function 'pr_stdio':
error:structure has no member named '_IO_file_flags'
error:'_IO_UNBUFFERED' undeclared
error:'_IO_LINE_BUF' undeclared
error:structure has no member named '_IO_buf_end'
error:structure has no member named '_IO_buf_base'
为什么会产生上面的错误呢?是不是哪个头文件没有引进来?
谢谢!
|
源代码里面说了:
/*
* The following is nonportable.
*/
检查一下你的机器上的/usr/include/stdio.h和/usr/include/libio.h,看看相应的字段应该是什么名字。
/*
* The following is nonportable.
*/
检查一下你的机器上的/usr/include/stdio.h和/usr/include/libio.h,看看相应的字段应该是什么名字。