This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

gcc-3.1: problems with filebuf constructor for FILE*


I'm in the process of upgrading some C++ code that compiled under gcc-3.0.* to
gcc-3.1. I am trying to migrate from using the basic_filebuf constructor that
accepted a FILE* to a new stdio_filebuf (from <ext/stdio_filebuf.h>), as explained
here:

http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#2

I find that __c_file_type (as used in <bits/basic_file.h>) is undefined when I
compile code that includes <ext/stdio_filebuf.h>. Introducing my own
"#define __c_file_type std::__c_file" seems to fix that.

Then I run into the problem that <bits/basic_file.h> is looking for _M_cfile
member variable that is no longer there, as shown below (at the bottom
of this e-mail). Adding my own
"#define _GLIBCPP_BASIC_FILE_ENCAPSULATION 1" seems to
alleviate that confusion.

Now I'm struggling with a conflict between const is_open methods at one level
that invoke non-const is_open methods, so I see the warning:

c++ -D__ACE_INLINE__ -gdwarf-2 -O2 -fPIC -Dcplusplus_2_1 -Wno-deprecated -I/home/scott/src/ivtools-1.0/src/ComTerp/LINUX/.. -I/home/scott/src/ivtools-1.0/src/ComTerp/LINUX/../.. -I/home/scott/src/ivtools-1.0/src -I/home/scott/src/ivtools-1.0/src/include -I/home/scott/src/ivtools-1.0/src/include/ivstd -I/usr/X11R6/include -c /home/scott/src/ivtools-1.0/src/ComTerp/LINUX/../comterpserv.c
/usr/local/include/g++-v3/fstream: In member function `bool
std::basic_filebuf<_CharT, _Traits>::is_open() const [with _CharT = char,
_Traits = std::char_traits<char>]':
/usr/local/include/g++-v3/ext/stdio_filebuf.h:97: instantiated from `__gnu_cxx::stdio_filebuf<_CharT, _Traits>::stdio_filebuf(std::__c_file*, std::_Ios_Openmode, _Traits::int_type) [with _CharT = char, _Traits = std::char_traits<char>]'
/home/scott/src/ivtools-1.0/src/ComTerp/comterpserv.c:157: instantiated from here
/usr/local/include/g++-v3/fstream:110: passing `const std::__basic_file<char>'
as `this' argument of `bool std::__basic_file<_CharT>::is_open() [with
_CharT = char]' discards qualifiers

Are these all oversights in the stdio_filebuf extension that have been corrected
for gcc-3.1.1, or am I simply grabbing this completely backwards? I haven't gotten
to linking yet, so I am also concerned with whether the _M_cfile member variable
will be there in the libstdc++-v3 object code. Can anyone with better oversight of
this evolution (and these classes) lend me a clue?

Thanks,

Scott Johnston

p.s. as always I would suggest an alternate approach to clearing up this mess with
regards to iostreams and file descriptors would be to implement an extension that
is 100% backward compatible with libstdc++-v2. I offer my source code
(http://www.ivtools.org) as a test-suite for such an approach, because I have
carefully preserved the prior style of iostreams/file-descriptor programming that
worked quite well for quite a while (and is still needed for all those out there who
haven't upgraded to a gcc-3.* compiler).


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

compiling without "#define _GLIBCPP_BASIC_FILE_ENCAPSULATION 1"

c++ -D__ACE_INLINE__ -gdwarf-2 -O2 -fPIC -Dcplusplus_2_1 -Wno-deprecated -I/home/scott/src/ivtools-1.0/src/ComTerp/LINUX/.. -I/home/scott/src/ivtools-1.0/src/ComTerp/LINUX/../.. -I/home/scott/src/ivtools-1.0/src -I/home/scott/src/ivtools-1.0/src/include -I/home/scott/src/ivtools-1.0/src/include/ivstd -I/usr/X11R6/include -c /home/scott/src/ivtools-1.0/src/ComTerp/LINUX/../comterpserv.c
In file included from /usr/local/include/g++-v3/bits/basic_file.h:250,
from /usr/local/include/g++-v3/fstream:48,
from /usr/local/include/g++-v3/ext/stdio_filebuf.h:30,
from /home/scott/src/ivtools-1.0/src/include/ivstd/fstream.h:9,
from /home/scott/src/ivtools-1.0/src/ComTerp/comterpserv.c:35:
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h: In
constructor `std::__basic_file<_CharT>::__basic_file(__c_lock*)':
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h:39: class `
std::__basic_file<_CharT>' does not have any field named `_M_cfile'
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h:39: class `
std::__basic_file<_CharT>' does not have any field named `_M_cfile_created'
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h: In member
function `std::__basic_file<_CharT>*
std::__basic_file<_CharT>::sys_open(std::__c_file*, std::_Ios_Openmode)
[with _CharT = char]':
/usr/local/include/g++-v3/ext/stdio_filebuf.h:96: instantiated from `__gnu_cxx::stdio_filebuf<_CharT, _Traits>::stdio_filebuf(std::__c_file*, std::_Ios_Openmode, _Traits::int_type) [with _CharT = char, _Traits = std::char_traits<char>]'
/home/scott/src/ivtools-1.0/src/ComTerp/comterpserv.c:157: instantiated from here
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h:87: `
_M_cfile' undeclared (first use this function)
/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/basic_file_model.h:87: (Each
undeclared identifier is reported only once for each function it appears
in.)




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