- 论坛徽章:
- 0
|
我有个程序,如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <error.h>
extern int errno;
int main(int argc,char ** argv[])
{
struct stat filestat;
int i_ret;
i_ret = stat("/tmp/aa.txt",&filestat);
if (i_ret != 0 && errno == ENOENT)
{
printf("文件不存在!\n");
return(1);
}
return(0);
}
用cc编译时提示如下:
bb.c: In function `main':
bb.c:17: `ENOENT' undeclared (first use in this function)
bb.c:17: (Each undeclared identifier is reported only once
bb.c:17: for each function it appears in.)
请问,宏ENOENT在哪里定义???
man 2 stat中有以下内容:
ERRORS
EBADF filedes is bad.
ENOENT A component of the path file_name does not exist, or the path is an empty string.
ENOTDIR
A component of the path is not a directory.
ELOOP Too many symbolic links encountered while traversing the path.
EFAULT Bad address.
EACCES Permission denied.
ENOMEM Out of memory (i.e. kernel memory).
ENAMETOOLONG
File name too long.
有哪位大虾知道呢??? |
|