Gcc Error Calling Fdopen Bad File Descriptor
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up calling fdopen: Bad file descriptor up vote 5 down vote favorite I'm getting the following error when trying to compile my program: calling fdopen: Bad file descriptor I've read this might be a problem related to including a precompiled header in one of my header files. The file which is causing the error includes the stdio.h header in it so I have access to the FILE type. If I remove this, the error disappears, but then I can't use the FILE type. Does anybody know how I can fix this? c gcc fdopen share|improve this question edited Sep 13 '11 at 4:08 Brian Webster 17.4k37115199 asked Feb 14 '10 at 19:43 LandonSchropp 3,8831247104 4 Try isolating the problem into a bare bones program (--i.e., a new seperate file with a main in it and only the code that fails). Then update your question. We can't give feedback without some code. –Hassan Syed Feb 14 '10 at 19:46 1 Can you post the simplest self-contained code that reproduces the issue you are experiencing? –Mark Byers Feb 14 '10 at 19:47 what version of gcc? –bmargulies Feb 14 '10 at 20:12 Source code please? We're not psychic debuggers nor clairvoyants... –t0mm13b Feb 16 '10 at 20:26 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote Hard to tell without details, but it's indeed most probably due to an out-of-date precompiled header. Remove all .gch files and try again. This is frequently reported as a bug against GCC, see the bugzilla entry here share|improve this answer answered Feb 16 '10 at 20:20 F'x 8,181553112 1 Thanks, this happened to be my issue. –Derrick May 2
"here I am" post here to differ human beings from SPAM bots. Home Help Search Login Register Wiki Code::Blocks » Developer forums (C::B DEVELOPMENT STRICTLY!) » Development » fdopen: Bad file descriptor « previous next » Send this topic Print Pages: [1] Go Down Author Topic: fdopen: Bad file descriptor (Read 12705 times) killerbot Administrator Lives here! Posts: 4971 fdopen: Bad file descriptor « on: August 14, 2007, 03:43:10 pm » Does anyone http://stackoverflow.com/questions/2262484/calling-fdopen-bad-file-descriptor else get this on linux : Quoteif g++ -DHAVE_CONFIG_H -I. -I. -I../../src/include -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -I../../src/include/wxscintilla/include -I../../src/include -I../../src/include/scripting/include -I../../src/include/scripting/sqplus -I../../src/include/wxFlatNotebook/include -I../../src/src/wxAUI -DENABLE_BINRELOC -DAPP_PREFIX="\"/usr/local\"" -Ulinux -Uunix -O2 -ffast-math -g -O2 -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -MT app.o -MD -MP -MF ".deps/app.Tpo" -c -o app.o app.cpp; \ then mv -f ".deps/app.Tpo" ".deps/app.Po"; http://forums.codeblocks.org/index.php?topic=6678.0 else rm -f ".deps/app.Tpo"; exit 1; fiIn file included from ../../src/include/logmanager.h:5, from app.cpp:55:../../src/include/logger.h:4:25: error: calling fdopen: Bad file descriptormake[3]: *** [app.o] Error 1 Logged killua Multiple posting newcomer Posts: 11 Re: fdopen: Bad file descriptor « Reply #1 on: August 14, 2007, 03:47:53 pm » Yeah, I got it just a bit ago, but I decided to do a make clean, and then a re-make. I'll see if I still get it after it gets to that point...[EDIT] Update: Still get the error after doing a make clean...will await a fix to be submitted before I proceed. « Last Edit: August 14, 2007, 03:58:51 pm by killua » Logged mandrav Project Leader Administrator Lives here! Posts: 4291 Re: fdopen: Bad file descriptor « Reply #2 on: August 14, 2007, 06:45:57 pm » Quote from: killerbot on August 14, 2007, 03:43:10 pmDoes anyone else get this on linux : Quoteif g++ -DHAVE_CONFIG_H -I. -I. -I../../src/include -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -
that line, I simply have #include "AnotherFile.h" Google told me this has something to do with precompiled headers, but I can't figure out how to turn http://www.cplusplus.com/forum/unices/1558/ them off. 1) how to turn off using precompiled headers with g++ flags? 2) what else would be causing this?? Thanks! Dave Apr 24, 2008 at 4:20am UTC rpgfan3233 (109) Try reordering https://www.daniweb.com/programming/software-development/threads/323995/calling-fdopen-bad-file-descriptor-and-undefined-reference the header files. I'm not sure if that will work, but it apparently worked for some test code at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13675 The bug was an issue with precompiled headers being included twice, gcc error which may be the case here. The same issue with fdopen() came up in that instance. Perhaps your problem and that bug are related to each other. Apr 27, 2008 at 7:52pm UTC hcben00 (1) I don't check here often so please forgive me if I never respond to any questions or responses... Solution to my similar problem after reading... Make sure the includes gcc error calling at the top of your headers and source are always in the same order and make sure the call to G++ is in the same order as listed in the top of the headers and source files. (Note: I didn't test the different combinations but I did get it to work my first try, this does assume the flexibility of having all sources.) Heres what I had trouble with 1
2
3
4
5
6
7
8
9
10
11
12
13
// Composition.h #include Increment.h #include Time.h // Composition.cpp #include "Composition.h" #include "Time.h" #include "Increment.h" // TestComposition.cpp #include "Time.h" #include "Increment.h" #include "Composition.h" my original G++ call g++ Increment.cpp Time.cpp Composition.cpp TestComposition.cpp -o TestComp My solution: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Composition.h (No difference) #include Increment.h #include Time.h // Composition.cpp (Big difference here) #include "Increment.h" #include "Time.h" #include "Composition.h" // TestComposition.cpp (Minor difference here) #include "Increment.h" #include "Time.h" #include "Composition.h" My G++ call stays the same: g++ Increment.cpp Time.cpp Composition.cpp TestComposition.cpp -o TestComp Topic archived. No new replies allowed. C++ Information Tutorials Reference Articles Forum Forum BeginnersWindows ProgrammingUNIX/Linux ProgrammingGeneral C++ ProgrammingLoungeJobs Home page | Privacy policy© cplusplus.com, 2000-2016 - All rights reserved - v3.1Spotted an error? contact us
Ago I'm trying to write a program which uses 4 class files. However, I've got some issue regarding the error I got from cygwin using g++ command, it says Calling fdopen: bad file descriptor when I try to include the files I need on top of my header files. I'll show all my codes here: 4 class files and 4 cpp files are shown here. Anyways, it would be great if someone could see if I'm doing wrong with the header. I've been getting all sorts of errors by just compiling and linking all files together(I created an empty int main(){} in each cpp files just for the sake of compiling) My main problem is when I tried to add files in both .h and .cpp files, the compiler complaints and even give me undefined reference despite the appropriate files are added. #ifndef DIVISIONLIST_H #define DIVISIONLIST_H #include "DivisionNode.h" #include "EmployeeNode.h" using namespace std; class DivisionList{ public: DivisionList(); ~DivisionList(); bool newDivision(int divNum); bool newEmployee(int emplNum,int divNum,char *firstName,char *lastName,double hours,double hourlyWage,int &error); bool deleteDivision(int divNum); EmployeeNode *locateEmployee(int emplNum); bool locateEmployee(int emplNum,int &divNum,char*& firstName,char*& lastName); bool deleteEmployee(int emplNum); void printDivision(int divNum); void printAll(); void insertDivisionNode(int divNum); private: DivisionNode* head; }; #endif #ifndef DIVISIONNODE_H #define DIVISIONNODE_H #include "EmployeeNode.h" #include "EmployeeList.h" using namespace std; class DivisionNode { public: DivisionNode(); DivisionNode(int divNum); ~DivisionNode(); int getDivisionNum(); DivisionNode* getNext(); void setDivisionNum(int divNum); void setNext(DivisionNode* n); bool newEmployee(int emplNum,char* firstName,char* lastName,double hours,double wourlyWage); EmployeeNode* locateEmployee(int emplNum); bool locateEmployee(int emplNum,char*& firstName,char*& lastName); bool deleteEmployee(int emplNum); void printEmployees(); private: int divisionNum; EmployeeList employees; DivisionNode* next; }; #endif #ifndef EMPLOYEELIST_H #define EMPLOYEELIST_H #include "DivisionNode.h" #include