3

我正在尝试在 cygwin(在 Windows 7 中)中编译一些源代码,并在运行 make 文件时出现以下错误

g++ -DHAVE_CONFIG_H -I. -I..  -I..  -Wall -Wextra -Werror -g -O2 -MT libcommon_a  Fcntl.o -MD -MP -MF .deps/libcommon_a-Fcntl.Tpo -c -o libcommon_a-Fcntl.o `test -f 'Fcntl.cpp' || echo './'`Fcntl.cpp
Fcntl.cpp: In function int setCloexec(int):
Fcntl.cpp:8: error: 'F_GETFD' was not declared in this scope
Fcntl.cpp:8: error: 'fcntl' was not declared in this scope
Fcntl.cpp:11: error: 'FD_CLOEXEC' was not declared in this scope
Fcntl.cpp:12: error: 'F_SETFD' was not declared in this scope
make[4]: *** [libcommon_a-Fcntl.o] Error 1
make[4]: Leaving directory `/abyss-1.1.2/Common'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/abyss-1.1.2'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/abyss-1.1.2'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/c/Users/Martin/Documents/NetBeansProjects/abyss-1.1.2_1'
make: *** [.build-impl] Error 2

问题文件是:-

#include "Fcntl.h"
#include <fcntl.h>


/* Set the FD_CLOEXEC flag of the specified file descriptor. */
int setCloexec(int fd)
{
 int flags = fcntl(fd, F_GETFD, 0);
 if (flags == -1)
  return -1;
 flags |= FD_CLOEXEC;
 return fcntl(fd, F_SETFD, flags);
}

我不明白发生了什么,文件 fcntl.h 可用,并且它所说的未在此范围内声明的变量在我自己编译文件时不会出错

任何帮助将非常感激

非常感谢

4

2 回答 2

1

我没有用 Cygwin 构建东西,所以这可能是不合时宜的,但考虑到你是在 Windows 上构建的,它有一个不区分大小写的文件系统,你确定编译器可以区分你的头文件Fcntl.h和系统头文件fcntl.h?它可能只是包含您的标头两次,而从未获得系统标头。

于 2010-05-17T21:23:08.383 回答
1

这些#include说法是怎么回事?您的项目中似乎有一个名为 的头文件Fcntl.h,对吗?里面有护卫吗?如果是这样,也许你不小心使用了与内置标题相同的保护,结果没有得到它的内容。Cygwin 通常在不区分大小写的文件系统上运行,因此即使给这些标头提供类似的名称也可能很危险。

于 2010-05-17T21:26:12.353 回答