簡體   English   中英

使用cygwin編譯c ++代碼的問題

[英]Problems compiliing c++ code using cygwin

我試圖在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是可用的,並且它所說的未在此范圍內聲明的varaiables在我自己編譯文件時不會出錯

任何幫助將非常感激

非常感謝

我沒有用Cygwin構建東西,所以這可能是偏離基礎的,但考慮到你在Windows上構建,它有一個不區分大小寫的文件系統,你確定編譯器可以區分你的頭文件Fcntl.h和系統頭文件fcntl.h 它可能只包括你的標題兩次,永遠不會得到系統標題。

那些#include語句怎么了? 看起來你的項目中有一個名為Fcntl.h的頭文件,是嗎? 它是否包括警衛? 如果是這樣,也許你不小心使用了與內置標題相同的保護,結果沒有得到它的內容。 Cygwin通常運行在不區分大小寫的文件系統上,所以即使給那些標題類似的名稱也許是危險的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM