Porting old non ansi code

T

TheDD

Hello all,

i've downloaded the source code of a GPL project but i don't manage to
compile it.

It have been written with an old g++ (<3) since there are #include <xxx.h>
and no std:: at all... In addition, all the C++ file extensions are '.C'
and '.h', makefile c++ compiler variable is "CC" with "CC-FLAGS"...

But others problems are harder to solve. For example, i have:

src/rec/Train.C: In member function `void Train::WriteTrainingFile(const
char*)':
src/rec/Train.C:272: aggregate `std::filebuf fbuff' has incomplete type and
cannot be defined

with:

272 filebuf fbuff;
273 fbuff.open( path, ios::eek:ut );
274 ostream out( &fbuff );

I don't see any problem...

Also, a g++ extension seems to be used: the "form()" function wich is used
like that:

out << form( TD_VersionFormat, TD_Version )

Do you know a macro i could define using ansi c++ so that the code can
compile?

I would like to correct the code and submit a path to these great searchers
but really poor programmers...

Thx by advance
 
J

John Harrison

TheDD said:
Hello all,

i've downloaded the source code of a GPL project but i don't manage to
compile it.

It have been written with an old g++ (<3) since there are #include <xxx.h>
and no std:: at all... In addition, all the C++ file extensions are '.C'
and '.h', makefile c++ compiler variable is "CC" with "CC-FLAGS"...

But others problems are harder to solve. For example, i have:

src/rec/Train.C: In member function `void Train::WriteTrainingFile(const
char*)':
src/rec/Train.C:272: aggregate `std::filebuf fbuff' has incomplete type and
cannot be defined

with:

272 filebuf fbuff;
273 fbuff.open( path, ios::eek:ut );
274 ostream out( &fbuff );

I don't see any problem...

Most likely a missing header file. Try

Also, a g++ extension seems to be used: the "form()" function wich is used
like that:

out << form( TD_VersionFormat, TD_Version )

Do you know a macro i could define using ansi c++ so that the code can
compile?

Can't see why the above wouldn't compile, assuming form is defined.

john
 
T

TheDD

Most likely a missing header file. Try

#include <fstream>
using namespace std;

yes, it works now, thx :)
Can't see why the above wouldn't compile, assuming form is defined.

well form() doesn't seems to be defined. I believe it's an old extension of
g++ wich has been deleted. But since i don't know the STL enough, i don't
know how to emulate the form() function.
 
J

John Harrison

TheDD said:
yes, it works now, thx :)


well form() doesn't seems to be defined. I believe it's an old extension of
g++ wich has been deleted. But since i don't know the STL enough, i don't
know how to emulate the form() function.

I've never heard of it, I don't think its ever been official STL. Taking a
wild guess it might be an attempt to do printf style formatting in an
iostream context, but I would ask on a gcc group to find out for certain.

john
 
D

David Mancel

I've never heard of it, I don't think its ever been official STL. Taking a
wild guess it might be an attempt to do printf style formatting in an
iostream context, but I would ask on a gcc group to find out for certain.

it's sure:
http://www.geocrawler.com/archives/3/364/1992/7/0/2055820/


my hack:
string form(const char *fmt, ...)
{
char tmp[2048];
va_list ap;
int res;

va_start(ap, fmt);
res = vsnprintf(tmp, 2046, fmt, ap);
va_end(ap);

return string(tmp);
}
 
T

TheDD

I've never heard of it, I don't think its ever been official STL. Taking a
wild guess it might be an attempt to do printf style formatting in an
iostream context, but I would ask on a gcc group to find out for certain.

john

it's sure:
http://www.geocrawler.com/archives/3/364/1992/7/0/2055820/


my hack:
string form(const char *fmt, ...)
{
char tmp[2048];
va_list ap;
int res;

va_start(ap, fmt);
res = vsnprintf(tmp, 2046, fmt, ap);
va_end(ap);

return string(tmp);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top