I’m making a makefile, and getting this error:
List.h:10:18: error: calling fdopen: Bad file descriptor
I have no idea why it happens.
Here’s the beginning of List.h:
#ifndef List_h__
#define List_h__
#include "Data.h"
#include "general.h"
where #include “Data.h” is the 10th line. Data and then general is the order in which the dependencies are written in the makefile:
List.o: List.cpp List.h Data.h general.h
g++ List.cpp $(f)
data doesn’t include anything and general includes only iostream, and no other class also includes iostream.
Here’s Data.h:
#ifndef Data_h__
#define Data_h__
class Data
{
private:
public:
//default constructor
Data() {}
//destructor
virtual ~Data()=0;
/*****************************************************************************
* function name: operator<
* The Input: This Data, other Data
* The output: The operator will compare between two datas. The comparison will
* be used to create a sorted list.
*****************************************************************************/
virtual bool operator<(const Data& other) const =0;
};
Data::~Data() {}
#endif //Data_h__
I initially had the trivial implementation of Data’s destructor after the =0, and I’ve also tried to move the trivial implementations of the constructor and destructor to a .cpp file. All of the above didn’t work. Please help – I’ve been stuck on this makefile for hours and it’s driving me crazy! Thanks!
First, check to see if you are using precompiled headers. If so delete all the precompiled headers.
If that doesn’t work, then I think this may help. There is a bug in some version of g++ with including a header multiple times in a single unit.
Look at see if you are including Data.h multiple times.
Precompiled headers: look for .gch files and delete them.
Precompiled header