I am trying to compile some source code in cygwin (in windows 7) and get the following error when I run the make file
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
The problem file is:-
#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);
}
I don't understand what is going on, the file fcntl.h is available and the varaiables that it says were not declared in this scope do not give an error when I compile the file on its own
开发者_开发技巧Any help would be much appreciated
Many Thanks
I've not built things with Cygwin, so this might be off-base, but considering that you're building on Windows, which has a case-insensitive filesystem, are you sure that the compiler can tell the difference between your header Fcntl.h
and the system header fcntl.h
? It might just be including your header twice and never getting the system header.
What's up with those #include
statements? It seems like you have a header file in your project called Fcntl.h
, is that right? Does it have include guards in it? If it does, maybe you're accidentally using the same guard as the built-in header, and as a result not getting its contents. Cygwin normally runs on a case-insensitive filesystem, so even giving those headers similar names like that is probably dangerous.
精彩评论