【发布时间】:2015-01-07 12:38:50
【问题描述】:
我想在我的程序中使用函数grantpt。我包含了它的头文件<stdlib.h>,但编译器仍然给我warning: implicit declaration of grantpt,这意味着它在stdlib.h 中找不到声明。我grep头文件,找到声明:
stdlib.h:920:extern int grantpt (int __fd) __THROW;
而我的glibc版本是2.17,官方手册上说是2.1以后才包含这个功能。
这是我的测试程序:
#include <stdio.h>
#include <stdlib.h>
typedef unsigned long u_l;
int main(){
int errno = grantpt(1);
printf("errno = %d\n", errno);
return 0;
}
非常感谢!
【问题讨论】:
-
如果您阅读the manual page,您会发现需要定义宏
_XOPEN_SOURCE,但显然不需要。
标签: c shared-libraries