This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: Linux vs. libio
- To: Per Bothner <per at bothner dot com>
- Subject: Re: Linux vs. libio
- From: Jamie Lokier <jamie dot lokier at cern dot ch>
- Date: Mon, 20 Dec 1999 18:18:01 +0100
- Cc: law at cygnus dot com, gcc at gcc dot gnu dot org, libc-alpha at sourceware dot cygnus dot com
- References: <3980.945695909@upchuck> <m21z8h1rmy.fsf@magnus.bothner.com>
Per Bothner wrote:
> Jeffrey A Law <law@cygnus.com> writes:
>
> > While I believe it was an unbelievably dumb thing for the glibc folks to
> > tie libio into the C library,
>
> In other words, you don't think it is a reasonable goal to allow C
> stdio FILEs to be shared with C++ iostream streambufs?
The down side is it's not at all portable, so code that's written on
Linux will output differently on other platforms.
> The best way to synchronize (say) stdout with cout seems to be for
> them both to use the same buffer. The requires (at least if you want
> efficiency) for them to use compatible data structures,
Only the /very/ few fields that are used by inline input/output
functions need to be shared. Since they are simple data fields, sharing
those would be very easy even with many different kinds of C++ ABI.
Everything else, including vtable format and placement does not need to
be shared. Just have the C library call functions (not virtual ones)
like "flush_my_output_stream" etc., and those functions would contain
the vtable lookup code. Or alternatively, have an explicit /C/ vtable
as one of the shared fields and keep it that way for the C++ version.
C++ streams don't have to call that vtable; they merely have to provide
it.
-- Jamie