* problems migrating to 3.2.3 from 2.96
@ 2004-09-20 22:20 Ashish Lakhani
2004-09-21 9:55 ` Claudio Bley
0 siblings, 1 reply; 4+ messages in thread
From: Ashish Lakhani @ 2004-09-20 22:20 UTC (permalink / raw)
To: gcc-help
Hi ,
I am new to gcc and c++ programming so i am looking for help in this
mailing list.
I have following piece of C++ code
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
functions.cc: In function `void ALCload(FILE*)':
functions.cc:188: invalid conversion from `int' to `const char*'
functions.cc:188: initializing argument 1 of
`std::basic_ifstream<_CharT,
_Traits>::basic_ifstream(const char*, std::_Ios_Openmode) [with
_CharT =
char, _Traits = std::char_traits<char>]'
functions.cc: In function `ALobject* ALLcryptdecrypt(ALobject*,
ALboolean)':
functions.cc:1626: `nocreate' is not a member of type
`std::basic_ios<char,
std::char_traits<char> >'
/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
functions.cc:1636: within this context
/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
functions.cc:1653: within this context
/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
functions.cc:1668: within this context
make: *** [functions.o] Error 1
I was wondering if anyone could help !!
Thanks,
Ashish
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: problems migrating to 3.2.3 from 2.96
2004-09-20 22:20 problems migrating to 3.2.3 from 2.96 Ashish Lakhani
@ 2004-09-21 9:55 ` Claudio Bley
0 siblings, 0 replies; 4+ messages in thread
From: Claudio Bley @ 2004-09-21 9:55 UTC (permalink / raw)
To: gcc-help
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: problems migrating to 3.2.3 from 2.96
2004-09-21 19:59 Ashish Lakhani
@ 2004-09-22 12:41 ` Claudio Bley
0 siblings, 0 replies; 4+ messages in thread
From: Claudio Bley @ 2004-09-22 12:41 UTC (permalink / raw)
To: gcc-help
Hello Ashish!
On Tue, Sep 21, 2004 at 12:58:43PM -0700, Ashish Lakhani wrote:
> 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.
Yes, I think it's OK. Although I would probably eliminate the iptr
variable altogether.
> 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.
Indeed, there already was someone facing the same problem with "nocreate"
even on this mailing list:
http://gcc.gnu.org/ml/gcc-help/2002-09/msg00219.html
I have no idea how to solve the other problem. Maybe if you elaborate
on that and explain in more detail why you need to call sync()?
--
Claudio
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: problems migrating to 3.2.3 from 2.96
@ 2004-09-21 19:59 Ashish Lakhani
2004-09-22 12:41 ` Claudio Bley
0 siblings, 1 reply; 4+ messages in thread
From: Ashish Lakhani @ 2004-09-21 19:59 UTC (permalink / raw)
To: Claudio Bley, gcc-help
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-09-22 12:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-20 22:20 problems migrating to 3.2.3 from 2.96 Ashish Lakhani
2004-09-21 9:55 ` Claudio Bley
2004-09-21 19:59 Ashish Lakhani
2004-09-22 12:41 ` Claudio Bley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).