Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] C++ compile probblem




Hi,

I'm in a bit of a daipaniku, I need to port a C++ programme from BSD to Linux. I did a 2 week C++ course a million years ago and can't remember any of it. If anyone could help me I'd be very thankful

Below is a fragment of the module with key line numbers pointed out, I don't know if this enough code to understand the problem.

Thanks,
Brett


I have the errors I'm receiving are:

IndexFile.cc: In constructor 'IndexFile::IndexFile(std::fstream&, int, int)':
IndexFile.cc:30: error: 'struct std::basic_filebuf<char, std::char_traits<char> >' has no member named 'fd'
IndexFile.cc:51: error: no matching function for call to 'std::basic_fstream<char, std::char_traits<char> >::read(size_t*&, long un
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/istream:456: note: candidates are: std::basic_istream<_CharT, _Tram<_CharT, _Traits>::read(_CharT*, std::streamsize) [with _CharT = char, _Traits = std::char_traits<char>]
IndexFile.cc: In destructor 'virtual IndexFile::~IndexFile()':
IndexFile.cc:64: error: no matching function for call to 'std::basic_fstream<char, std::char_traits<char> >::write(size_t*&, long u
/usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/ostream.tcc:483: note: candidates are: std::basic_ostream<_Csic_ostream<_CharT, _Traits>::write(const _CharT*, std::streamsize) [with _CharT = char, _Traits = std::char_traits<char>]
IndexFile.cc: In member function 'virtual int IndexFile::readBlock(char*, blockno_t, size_t)':
IndexFile.cc:364: warning: comparison between signed and unsigned integer expressions
make: *** [IndexFile.o] Error 1
$


The module is :
---------------------------------------
IndexFile::IndexFile(fstream &file, int rdonlyp, int newfilep)
: idxfile(file), readonlyp(rdonlyp), blockNum(0)
{
freeSizeTbl = new size_t[MAXBLOCKNUM];
memset(freeSizeTbl, 0, MAXBLOCKNUM * sizeof(size_t));

if(! newfilep){
// read table from the file tail
struct stat fstatus;
// line 30
fstat(idxfile.rdbuf()->fd(), &fstatus);
off_t filesize = fstatus.st_size;
// cerr << "filesize = " << filesize << endl;

int tailblkNum; // t?tail table?????????[35;9Hfor(tailblkNum = 0; ; tailblkNum++)

if((int)((filesize % BLOCKSIZE + tailblkNum * BLOCKSIZE
- sizeof(MAGIC))/sizeof(size_t))
>= (filesize / BLOCKSIZE) - tailblkNum ) break;

blockNum = filesize / BLOCKSIZE - tailblkNum;

// check magic string
char magic[sizeof(MAGIC)];
idxfile.clear();
idxfile.seekg(blockNum * BLOCKSIZE, ios::beg);
idxfile.read(magic, sizeof(MAGIC));
if(0 != strcmp(magic, MAGIC)){
PRINTERRMSG("MAGIC check fail!");
}else{
// idxfile.seekg(0);
// line 51
idxfile.read(freeSizeTbl, sizeof(freeSizeTbl[0]) * blockNum);
assert(sizeof(freeSizeTbl[0]) * blockNum ==
filesize - blockNum*BLOCKSIZE - sizeof(MAGIC));
}
}
}

IndexFile::~IndexFile(){
if(! readonlyp){
//cout << "write MAGIC, blockNum =" << blockNum << endl;
idxfile.seekp(blockNum * BLOCKSIZE, ios::beg);
idxfile.clear();
idxfile.write(MAGIC, sizeof(MAGIC));
// line 64
idxfile.write(freeSizeTbl, blockNum * sizeof(freeSizeTbl[0]));
}
idxfile.close();
if(freeSizeTbl) delete []freeSizeTbl;
}



---------------------------------------


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links