This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: problems migrating to 3.2.3 from 2.96


Hi Claudio ,

Thanks for your help!!

I have replaced my existing function  

 void ALCload(FILE * infile)
 {
     istream *iptr;
     ifstream * ifptr;
     int fd = fileno(infile);
     ifptr = new ifstream(fd);
     iptr = ifptr;
     ALCload(iptr);
     return;
 }

with this 

void ALCload(FILE * infile)
{
    istream *iptr;
    stdiobuf p_buf (infile, ios::in);
    istream istr (&p_buf);
    iptr = &istr;
    ALCload(iptr);
    return;
}
I guess new code should work in similar fashion as earlier one.

However there is another piece of code which is not giving problems 
if(fptr->open(strPtr, std::ios::in | std::ios::out | std::ios::nocreate)
== 0) 

gcc gives following error  `nocreate' is not a member of type
`std::basic_ios<char, std::char_traits<char> >'

and also fptr->sync();
gives error
/usr/include/c++/3.2.3/fstream:191: `int
std::basic_filebuf<_CharT,_Traits>::sync() [with _CharT = char, _Traits
= std::char_traits<char>]' is protected

I was wondering if anyone has faced similar compiler problems in past
and any they any workaround/solutions they might want to suggest.

Thanks,
Ashish


-----Original Message-----
From: Claudio Bley [mailto:bley@CS.uni-magdeburg.de] 
Sent: Tuesday, September 21, 2004 2:56 AM
To: gcc-help@gcc.gnu.org
Subject: Re: problems migrating to 3.2.3 from 2.96

Hi.

On Mon, Sep 20, 2004 at 03:19:59PM -0700, Ashish Lakhani wrote:
> void ALCload(FILE * infile)
> {
>     istream *iptr;
>     ifstream * ifptr;
>     int fd = fileno(infile);
>     ifptr = new ifstream(fd);
>     iptr = ifptr;
>     ALCload(iptr);
>     return;
> }
> 
> it used to compile fine with gcc version 2.96 but in new gcc 3.2.3 it
> generates following errors

[...]

You can't create an ifstream from a file descriptor or FILE pointer. 
This feature has been removed because the C++ standard does not define
it 
since it is inherently system dependent and non-portable.

The only constructor ifstream provides is this

explicit ifstream ( const char * filename, openmode mode = in );


However, there is a GCC extension available you could use. Just have 
a look at the ext/stdio_filebuf.h header.

Here is an example:

http://gcc.gnu.org/ml/gcc-help/2004-02/msg00230.html

--
Claudio


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]