Connecting Tech Pros Worldwide Help | Site Map

Porting old non ansi code

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:48 AM
TheDD
Guest
 
Posts: n/a
Default Porting old non ansi code

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::out );
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

--
TheDD

  #2  
Old July 22nd, 2005, 06:48 AM
John Harrison
Guest
 
Posts: n/a
Default Re: Porting old non ansi code


"TheDD" <pas.d@email.com> wrote in message
news:cwyeoy4j33qz$.36kshb56pr5b.dlg@40tude.net...[color=blue]
> 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[/color]
and[color=blue]
> cannot be defined
>
> with:
>
> 272 filebuf fbuff;
> 273 fbuff.open( path, ios::out );
> 274 ostream out( &fbuff );
>
> I don't see any problem...[/color]

Most likely a missing header file. Try

#include <fstream>
using namespace std;
[color=blue]
>
> 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?[/color]

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

john


  #3  
Old July 22nd, 2005, 06:48 AM
TheDD
Guest
 
Posts: n/a
Default Re: Porting old non ansi code

On Mon, 23 Feb 2004 22:06:41 -0000, John Harrison wrote:
[color=blue]
> Most likely a missing header file. Try
>
> #include <fstream>
> using namespace std;[/color]

yes, it works now, thx :)
[color=blue]
> Can't see why the above wouldn't compile, assuming form is defined.[/color]

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.

--
TheDD
  #4  
Old July 22nd, 2005, 06:48 AM
John Harrison
Guest
 
Posts: n/a
Default Re: Porting old non ansi code


"TheDD" <pas.d@email.com> wrote in message
news:1xq5edlc8hnqv$.1tw7tgtw7wzyc$.dlg@40tude.net. ..[color=blue]
> On Mon, 23 Feb 2004 22:06:41 -0000, John Harrison wrote:
>[color=green]
> > Most likely a missing header file. Try
> >
> > #include <fstream>
> > using namespace std;[/color]
>
> yes, it works now, thx :)
>[color=green]
> > Can't see why the above wouldn't compile, assuming form is defined.[/color]
>
> well form() doesn't seems to be defined. I believe it's an old extension[/color]
of[color=blue]
> g++ wich has been deleted. But since i don't know the STL enough, i don't
> know how to emulate the form() function.
>[/color]

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


  #5  
Old July 22nd, 2005, 06:48 AM
David Mancel
Guest
 
Posts: n/a
Default Re: Porting old non ansi code

On Mon, 23 Feb 2004 22:30:03 -0000, John Harrison wrote:
[color=blue]
> "TheDD" <pas.d@email.com> wrote in message
> news:1xq5edlc8hnqv$.1tw7tgtw7wzyc$.dlg@40tude.net. ..[color=green]
>> On Mon, 23 Feb 2004 22:06:41 -0000, John Harrison wrote:
>>[color=darkred]
>>> Most likely a missing header file. Try
>>>
>>> #include <fstream>
>>> using namespace std;[/color]
>>
>> yes, it works now, thx :)
>>[color=darkred]
>>> Can't see why the above wouldn't compile, assuming form is defined.[/color]
>>
>> well form() doesn't seems to be defined. I believe it's an old extension[/color]
> of[color=green]
>> g++ wich has been deleted. But since i don't know the STL enough, i don't
>> know how to emulate the form() function.
>>[/color]
>
> 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.[/color]

it's sure:
http://www.geocrawler.com/archives/3...2/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);
}


--
David Mancel
SCIA 2005
  #6  
Old July 22nd, 2005, 06:48 AM
TheDD
Guest
 
Posts: n/a
Default Re: Porting old non ansi code

On Mon, 23 Feb 2004 22:30:03 -0000, John Harrison wrote:
[color=blue]
> 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[/color]

it's sure:
http://www.geocrawler.com/archives/3...2/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);
}

--
TheDD
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.